06
Jul
Learn how to use Codeigniter Active Records join
Codeigniter Active Record syntax for join
$this->db->join();
Ex:
$this->db->select('*'); $this->db->from('user'); $this->db->join('review', 'review.id = user.id'); $query = $this->db->get();
And it will generate following sql.
SELECT * FROM user JOIN review ON review.id = user.id
if you need several joins in one query, you have to call join function multiple times.
If you need a specific type of JOIN you can specify it via the third parameter of the function.
Options are: left, right, outer, inner, left outer, and right outer.
Ex
$this->db->join('review', 'review.id = user.id', 'left'); // Produces: LEFT JOIN review ON review.id = user.id