Free Download latest collection of Student Projects for Computer Science, IT and final year students.Students can get source code of these projects as well.
Tuesday, 10 February 2015
Multiple Joins in Codeigniter in PHP
Multiple Joins in Codeigniter in PHP
This code show Multiple Joins in Codeigniter.You can use this code in your projects to ease your work.
$this->db->select('*');
$this->db->from('TableA AS A');// I use aliasing make joins easier
$this->db->join('TableC AS C', 'A.ID = C.TableAId', 'INNER');
$this->db->join('TableB AS B', 'B.ID = C.TableBId', 'INNER');
$result = $this->db->get();
The join function works like this:
join('TableName', 'ON condition', 'Type of join');
The equivalent SQL:
$this->db->select('*');
$this->db->from('TableA AS A');// I use aliasing make joins easier
$this->db->join('TableC AS C', 'A.ID = C.TableAId', 'INNER');
$this->db->join('TableB AS B', 'B.ID = C.TableBId', 'INNER');
0 comments:
Post a Comment