在我的表单中,有一些值要插入到多个表中。插入到第一个表后,我必须将其他值以及条目的“id”插入到第一个表中作为参考。做这个的最好方式是什么?有什么codeigniter特定的方法吗?
问问题
2720 次
2 回答
5
$this->db->insert_id()
可能是您正在寻找的东西。这是它如何工作的示例:
$this->db->insert('Table1',$values);
$table1_id=$this->db->insert_id();
$otherValues=array(
'table1_id'=>$table1_id,
);
$this->db->insert('otherTable',$otherValues);
于 2010-06-30T17:09:26.577 回答
1
尝试使用mysql_insert_id ();
于 2010-06-30T16:57:32.757 回答