tags:

views:

43

answers:

1

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?

A: 

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); 
Matthew
is there a way to bind query in one statement for advance select statements like joins etc ?
sagarmatha