alhamadm
alhamadm

Reputation: 1

Join does not work

I have write a function using SQL join but i do not know why it does not work

this is a model

public function get_contract_user($user_id) 
{
    $this->db->select('contracts.*');
    $this->db->from('contracts');       
    $this->db->join('link', 'contracts.contract_id = link.contracts_contract_id');
    $this->db->where('link.users_user_id', $user_id); 
    $query = $this->db->get();  
    return $query->result(); 
}

this is the app

$data['query'] = $this->admin_model->get_contract_user($contract_id);

this is a view

foreach($query as $row) 
{       
    echo $row->contract_code; 
    echo $row->contract_num;
    echo $row->contract_start;
    echo $row->contract_end;
}

Upvotes: 0

Views: 60

Answers (1)

matt
matt

Reputation: 367

You defined method get_contract_user, but you are using get_contract in provided code.

You should be getting an error concerning undefined function/method.

Upvotes: 3

Related Questions