This commit is contained in:
2020-09-06 04:28:57 +08:00
parent 618c905f7a
commit a0bb92f0a7
+14 -12
View File
@@ -66,13 +66,14 @@ class Connection extends Pool
if (!Context::hasContext('begin_' . $coroutineName)) { if (!Context::hasContext('begin_' . $coroutineName)) {
Context::setContext('begin_' . $coroutineName, 0); Context::setContext('begin_' . $coroutineName, 0);
} }
if (Context::getContext('begin_' . $coroutineName) === 0) {
$connection = Context::getContext($coroutineName);
if ($connection instanceof PDO && !$connection->inTransaction()) {
$connection->beginTransaction();
}
}
Context::autoIncr('begin_' . $coroutineName); Context::autoIncr('begin_' . $coroutineName);
if (!Context::getContext('begin_' . $coroutineName) !== 0) {
return;
}
$connection = Context::getContext($coroutineName);
if ($connection instanceof PDO && !$connection->inTransaction()) {
$connection->beginTransaction();
}
} }
/** /**
@@ -88,12 +89,13 @@ class Connection extends Pool
return; return;
} }
$connection = Context::getContext($coroutineName); $connection = Context::getContext($coroutineName);
if ($connection instanceof PDO) { if (!($connection instanceof PDO)) {
if ($connection->inTransaction()) { return;
$this->info('connection commit.'); }
$connection->commit(); Context::setContext('begin_' . $coroutineName, 0);
} if ($connection->inTransaction()) {
Context::setContext('begin_' . $coroutineName, 0); $this->info('connection commit.');
$connection->commit();
} }
} }