关于事务回滚无效

浏览:1523 发布日期:2016/07/23 分类:求助交流
以下是在model里的一个方法,$commit变量最后是false,然后也执行了rollback(),但是数据库里的数据却已经更新和删除了,没有回滚,这是什么原因? public function CombineAccout($phonenum,$openid){
        $openid_customerid = $this->where(["openid"=>$openid])->getField("customer_ID");
        $phonenum_customerid = $this->where(["phonenum"=>$phonenum])->getField("customer_ID");
        $commit = true;
        $this->startTrans();

        if($phonenum_customerid){//已存在手机账户,转移数据
            if(!M("orders")->where(["customerid"=>$phonenum_customerid])->save(["customerid"=>$openid_customerid]))
                $commit=false;
            if(!$this->where(["customer_ID"=>$phonenum_customerid])->delete())
                $commit=false;
        }
        if(!$this->where(["customer_ID"=>$openid_customerid])->save(["phonenum"=>$phonenum]))
            $commit=false;

        if($commit)
        {
            return $this->commit();
        }else{
            $this->rollback();
            return false;
        }
    }
最佳答案
评论( 相关
后面还有条评论,点击查看>>