In my form, there are values to be inserted to multiple tables. After inserting to the first table, i have to insert the other values, along with the 'id' of the entry to first table as reference. What is the best way to do this? Is there any codeigniter specific way?
views:
206answers:
2
+3
A:
$this->db->insert_id()
may be what you're looking for. Here's an example of how it could work:
$this->db->insert('Table1',$values);
$table1_id=$this->db->insert_id();
$otherValues=array(
'table1_id'=>$table1_id,
);
$this->db->insert('otherTable',$otherValues);
stormdrain
2010-06-30 17:09:26