如何在代码点火器中将一个函数 ID 分配给控制器中的其他函数



我想为我在companyProfileDetails()中获得的其他功能提供公司 ID

我在控制器中的代码是:

public function company_profile()
{
    $data['compData'] = $this->company_model->companyProfileDetails($this->session->userdata('peo_id'));
    $data['compAgentData'] = $this->company_model->companyAgentDetails($compData->cmp_id);
    $this->load->view('company_profile',$data);
}

我在模型中的代码:

public function companyProfileDetails($peo_id)
{
    $sql = "SELECT * FROM company left join people_company on people_company.pcy_company_id = company.cmp_id where people_company.pcy_people_id ='".$peo_id."'";
    $query = $this->db->query($sql);
    return $query->row();
}
public function companyAgentDetails($cmp_id)
{
    $sql = "SELECT peo_id,peo_name FROM people_company left join people on people.peo_id = people_company.pcy_people_id WHERE people_company.pcy_company_id ='23' ";
    $query = $this->db->query($sql);
    return $query->result();
}

像这样尝试。

public function company_profile()
{ 
    $data['compData'] = $this->company_model->companyProfileDetails($this->session->userdata('peo_id'));
    $data['compAgentData'] = $this->company_model->companyAgentDetails($data['compData']->cmp_id);
    $this->load->view('company_profile',$data);
}

public function company_profile()
{ 
    $compData = $this->company_model->companyProfileDetails($this->session->userdata('peo_id'));//Get row data
     $id = $compData->cmp_id;//get row's id
    $data['compAgentData'] = $this->company_model->companyAgentDetails($id);
    $data['compData'] = $compData;
    $this->load->view('company_profile',$data);
}

相关内容

  • 没有找到相关文章

最新更新