think-orm
think-orm copied to clipboard
There is no active transaction 错误出现的原因
下面这段代码不够严谨,希望能够处理一下

PDOConnection
public function transaction(callable $callback) { $this->startTrans();
try {
$result = null;
if (is_callable($callback)) {
$result = $callback($this);
}
$this->commit();
return $result;
} catch (\Exception | \Throwable $e) {
$this->rollback();
throw $e;
}
}
这里面的 $this->rollback(); 这个一旦抛错,实际的错误就看不到了,其实实际的错误是 SQLSTATE[HY000]: General error: 1364 Field 'accessName' doesn't have a default value
自行分拆步骤吧,这种更具体的处理逻辑还是自己写的好