//开启事务
Db::startTrans();
try{
//参数1:返回的错误信息;参数2:返回的值.
throw new \Exception('错误信息',1000);
//事务提交
Db::commit();
return true;
}catch (\Exception $e){
//事务回滚
Db::rollback();
if ($e->getCode()===1000){
return json(returnJson(2,$e->getMessage,''));
}
return false;
}