开发中,数据库Insert使用了事务,若是数据库
$this->db->insert_id()
放在this
$this->db->trans_complete();
这句语句以后,$this->db->insert_id()
会返回0,获取不到值;code
在开启事务的状况下,要将$this->db->insert_id()
放在$this->db->trans_complete();
以前。事务
如:开发
$this->db->trans_start(); $this->db->insert('table',$data); $id = $this->db->insert_id(); $this->db->trans_complete();