开发中,数据库Insert使用了事务,如果

$this->db->insert_id()

放在

$this->db->trans_complete();

这句语句之后,$this->db->insert_id()会返回0,获取不到值;

在开启事务的情况下,要将$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();

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2021-09-09
  • 2021-12-15
相关资源
相似解决方案