【发布时间】:2014-01-22 02:22:33
【问题描述】:
型号:
$data = array( 'firstname' => $fname,
'lastname' => $lname );
$result = $this->db->insert('users',$data);
假设代码插入了一个新行。在桌子上,我有 3 列,id,username,pass。 id 是自动递增的。插入后,我将如何检索新插入行的 id。假设我要插入至少 2 行并具有相同的名字或姓氏。
这是我的计划,我还不确定它是否会起作用。
$sql = $this->db
->select('id')
->where(' ', $variable)
->from('user')
->get()
->result_array();
我不确定在 where 子句上放什么,因为它可能包含具有相同名字和姓氏的行。我需要获取新插入行的自动递增 id。 id也是我的PK。
【问题讨论】:
标签: jquery database codeigniter