Skip to content

Commit 4b5ef9e

Browse files
authored
fix pdo exception when rollbacking without active transaction (#46017)
1 parent 3b8057c commit 4b5ef9e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Illuminate/Database/Concerns/ManagesTransactions.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ public function rollBack($toLevel = null)
290290
protected function performRollBack($toLevel)
291291
{
292292
if ($toLevel == 0) {
293-
$this->getPdo()->rollBack();
293+
$pdo = $this->getPdo();
294+
295+
if ($pdo->inTransaction()) {
296+
$pdo->rollBack();
297+
}
294298
} elseif ($this->queryGrammar->supportsSavepoints()) {
295299
$this->getPdo()->exec(
296300
$this->queryGrammar->compileSavepointRollBack('trans'.($toLevel + 1))

0 commit comments

Comments
 (0)