改名
This commit is contained in:
@@ -53,11 +53,7 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
public function inTransaction($cds): bool
|
public function inTransaction($cds): bool
|
||||||
{
|
{
|
||||||
$coroutineName = $this->name($cds, true);
|
return Context::getContext('begin_' . $this->name($cds, true)) == 0;
|
||||||
if (!Context::hasContext('begin_' . $coroutineName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Context::getContext('begin_' . $coroutineName) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,7 +93,6 @@ class Connection extends Pool
|
|||||||
}
|
}
|
||||||
Context::setContext('begin_' . $coroutineName, 0);
|
Context::setContext('begin_' . $coroutineName, 0);
|
||||||
if ($connection->inTransaction()) {
|
if ($connection->inTransaction()) {
|
||||||
$this->info('connection commit.');
|
|
||||||
$connection->commit();
|
$connection->commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,11 +120,8 @@ class Connection extends Pool
|
|||||||
if (Context::autoDecr('begin_' . $coroutineName) > 0) {
|
if (Context::autoDecr('begin_' . $coroutineName) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($this->hasClient($coroutineName)) {
|
if (($connection = Context::getContext($coroutineName)) instanceof PDO) {
|
||||||
/** @var PDO $connection */
|
|
||||||
$connection = Context::getContext($coroutineName);
|
|
||||||
if ($connection->inTransaction()) {
|
if ($connection->inTransaction()) {
|
||||||
$this->info('connection rollBack.');
|
|
||||||
$connection->rollBack();
|
$connection->rollBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,7 +246,6 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
public function connection_clear()
|
public function connection_clear()
|
||||||
{
|
{
|
||||||
$this->debug('receive all clients.');
|
|
||||||
$connections = Context::getAllContext();
|
$connections = Context::getAllContext();
|
||||||
foreach ($connections as $name => $connection) {
|
foreach ($connections as $name => $connection) {
|
||||||
if (empty($connection) || !($connection instanceof PDO)) {
|
if (empty($connection) || !($connection instanceof PDO)) {
|
||||||
@@ -289,9 +280,6 @@ class Connection extends Pool
|
|||||||
public function checkCanUse($name, $time, $client): bool
|
public function checkCanUse($name, $time, $client): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($time + 60 * 10 > time()) {
|
|
||||||
return $result = true;
|
|
||||||
}
|
|
||||||
if (empty($client) || !($client instanceof PDO)) {
|
if (empty($client) || !($client instanceof PDO)) {
|
||||||
return $result = false;
|
return $result = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user