Skip to content

Commit 28f7227

Browse files
authored
Update Middleware.php
1 parent 1e1fe10 commit 28f7227

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Middleware.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,12 @@ protected function checkTpUncommittedTransaction(): string
272272
$instances = $property->getValue($manager_instance);
273273
foreach ($instances as $connection) {
274274
/* @var \think\db\connector\Mysql $connection */
275-
$pdo = $connection->getPdo();
276-
if ($pdo && $pdo->inTransaction()) {
277-
$connection->rollBack();
278-
$logs .= "[ERROR]\tUncommitted transaction found and try to rollback" . PHP_EOL;
275+
if (method_exists($connection, 'getPdo')) {
276+
$pdo = $connection->getPdo();
277+
if ($pdo && $pdo->inTransaction()) {
278+
$connection->rollBack();
279+
$logs .= "[ERROR]\tUncommitted transaction found and try to rollback" . PHP_EOL;
280+
}
279281
}
280282
}
281283
} catch (Throwable $e) {

0 commit comments

Comments
 (0)