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 事物回滚测试
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('成功提示');
}
