How to query from two tables in codeigniter using active record?
Hi friends How do we query from two tables in codeigniter using active record ? Can anyone pls 开发者_如何学编程show me how to insert in the fields of two tables while adding fields?
Just use separate queries.
For selecting:
$query1 = $this->db->get('table1');
$query2 = $this->db->get('table2');
For inserting
$data1 = array(
'title1' => 'My title1' ,
'name1' => 'My Name1'
);
$this->db->insert('table1', $data);
$data1 = array(
'title2' => 'My title2' ,
'name2' => 'My Name2'
);
$this->db->insert('table2', $data);
精彩评论