/**
* 启动事务
* @access public
* @return void
*/
public function startTrans() {
$this->commit();
$this->db->startTrans();
return ;
}
而在mysqli驱动(即$this->db)中是这样实现的: /**
* 启动事务
* @access public
* @return void
*/
public function startTrans() {
$this->initConnect(true);
//数据rollback 支持
if ($this->transTimes == 0) {
$this->_linkID->autocommit(false);
}
$this->transTimes++;
return ;
}
既然在Model类的startTrans()中已经提交了事务,那在Mysqli底层再通过$this->transTimes判断是不是需要启用事务还有啥意义?无论你在Model对象中调用几次startTrans(),都会是一个新的事务了!这直接导致关联模型的增删改和被关联模型事务的不统一! 最佳答案
