我在数据库表中成功插入记录。主键(member_id)设置为auto_increment。我想在插入成员记录并创建新的member_id时,立即从同一查询中检索相同的记录ID。这可能吗?
此致
答案 0 :(得分:1)
$this->db->insert_id()
将从数据库中获取最新的ID。
请参阅:http://ellislab.com/codeigniter/user-guide/database/helpers.html
答案 1 :(得分:0)
$this->db->insert('...');
$member_id = mysql_insert_id();
这也可以,它是标准的PHP函数。 http://www.w3schools.com/php/func_mysql_insert_id.asp