【发布时间】:2010-06-30 16:49:51
【问题描述】:
在我的表单中,有一些值要插入到多个表中。 插入第一个表后,我必须插入其他值, 连同第一个表的条目的“id”作为参考。是什么 最好的方法是什么?有什么codeigniter特定的方法吗?
【问题讨论】:
标签: php mysql codeigniter lastinsertid
在我的表单中,有一些值要插入到多个表中。 插入第一个表后,我必须插入其他值, 连同第一个表的条目的“id”作为参考。是什么 最好的方法是什么?有什么codeigniter特定的方法吗?
【问题讨论】:
标签: php mysql codeigniter lastinsertid
$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);
【讨论】:
尝试使用mysql_insert_id ();
【讨论】: