CI框架的事务开启、提交和回滚

1.运行事务

$this->db->trans_start();  // 开启事务
$this->db->query('一条SQL查询...');
$this->db->query('另一条查询...');
$this->db->query('还有一条查询...');
$this->db->trans_complete()
;  // 提交事务

$this->db->trans_start();  // 开启事务
$this->db->query('一条SQL查询或者添加数据或者删除数据...');  // 执行查询
$this->db->trans_rollback();  // 事务回滚

猜你喜欢

转载自www.cnblogs.com/jingmin/p/9084019.html
今日推荐