官方源代码
vendor/topthink/think-orm/src/db/PDOConnection.php :1369行publicfunctionstartTrans():void
{
$this->initConnect(true);
++$this->transTimes;
try{
if(1==$this->transTimes){
$this->linkID->beginTransaction();
}elseif($this->transTimes>1&&$this->supportSavepoint()){
$this->linkID->exec(
$this->parseSavepoint('trans'.$this->transTimes)
);
}
$this->reConnectTimes=0;
}catch(\Exception$e){
if($this->reConnectTimesisBreak($e)){
--$this->transTimes;
++$this->reConnectTimes;
$this->close()->startTrans();
}
throw$e;
}
}修复建议: 在"throw $e;"上面加个else或 使用return阻止抛出异常publicfunctionstartTrans():void
{
$this->initConnect(true);
++$this->transTimes;
try{
if(1==$this->transTimes){
$this->linkID->beginTransaction();
}elseif($this->transTimes>1&&$this->supportSavepoint()){
$this->linkID->exec(
$this->parseSavepoint('trans'.$this->transTimes)
);
}
$this->reConnectTimes=0;
}catch(\Exception$e){
if($this->reConnectTimesisBreak($e)){
--$this->transTimes;
++$this->reConnectTimes;
$this->close()->startTrans();
}else{
throw$e;
}
}
}