Tutorialsplane

Codeigniter join with multiple conditions


$this->db->join(); is used to join tables in codeigniter.

Codeigniter join with multiple conditions


$this->db->select('*');
$this->db->from('users');
$this->db->join('profile_image', ' ( profile_image.user_id = users.id  AND  profile_image.is_active="1" )');
$this->db->join('city', 'city.user_id = users.id','left');
$this->db->where('users.id', $id); 
$query = $this->db->get();

Will produce
// Select *from users join profile_image
on ( profile_image.user_id = users.id AND profile_image.is_active=”1″ )
left join city on city.user_id = users.id where users.id = $id