当前位置 : 主页 > 网络编程 > PHP >

thinkphp3.2.3 事物操作回滚测试

来源:互联网 收集:自由互联 发布时间:2021-06-28
thinkphp3.2.3事物操作回滚测试 //thinkphp3.2.3事物回滚测试publicfunctionindex(){M()-startTrans();//开启事务$map['id']=1;//添加条件$data['email']='11111456@qq.com';$user=M('open_user')-lock(true)-where($map)-save($data);
thinkphp3.2.3 事物操作回滚测试
//thinkphp3.2.3 事物回滚测试
    public function index(){
		M()->startTrans();  //开启事务
        $map['id']=1;       //添加条件
		$data['email'] = '11111456@qq.com';
        $user = M('open_user')->lock(true)->where($map)->save($data);//加锁
        if($user){
            //执行你想进行的操作, 最后返回操作结果 result


            $result = false;
            if($result){
                M()->rollback();//回滚
                $this->error('错误提示');
            }
        }
        M()->commit();//事务提交
        $this->success('成功提示');
	}
网友评论