轉載:原文地址
try{
'數據庫操作';
Db::commit();
$this->success("成功")
}cathe(\Exception $exception){
Db::rollback();
$this->error("成功");
}
問題解析:$this->success();的源碼其實也是會拋出異常
解決方法:
將
catch (\Exception $exception)
改成
catch (\think\Exception\DbException $exception)