Codeigniter joins example


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


Codeigniter joins example


$this->db->select('*');
$this->db->from('users');
$this->db->join('profile_image', 'profile_image.user_id = users.id');
$query = $this->db->get();

Will produce

// Select *from users join profile_image on profile_image.user_id = users.id

More Codeigniter joins example


$this->db->select('*');
$this->db->from('users');
$this->db->join('profile_image', 'profile_image.user_id = users.id');
$this->db->where('users.id', $id); 
$query = $this->db->get();

Will produce the query

// Select *from users join profile_image on profile_image.user_id = users.id where users.id = $id


Advertisements

Add Comment

📖 Read More