改名
This commit is contained in:
+13
-13
@@ -51,10 +51,10 @@ class Connection extends Pool
|
|||||||
public function inTransaction($cds)
|
public function inTransaction($cds)
|
||||||
{
|
{
|
||||||
[$coroutineId, $coroutineName] = $this->getIndex($cds, true);
|
[$coroutineId, $coroutineName] = $this->getIndex($cds, true);
|
||||||
if (!Context::hasContext('begin_' . $coroutineName)) {
|
if (!Context::hasContext('begin_' . $coroutineName, $coroutineId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Context::getContext('begin_' . $coroutineName) == 0;
|
return Context::getContext('begin_' . $coroutineName, $coroutineId) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,16 +63,16 @@ class Connection extends Pool
|
|||||||
public function beginTransaction($coroutineName)
|
public function beginTransaction($coroutineName)
|
||||||
{
|
{
|
||||||
[$coroutineId, $coroutineName] = $this->getIndex($coroutineName, true);
|
[$coroutineId, $coroutineName] = $this->getIndex($coroutineName, true);
|
||||||
if (!Context::hasContext('begin_' . $coroutineName)) {
|
if (!Context::hasContext('begin_' . $coroutineName, $coroutineId)) {
|
||||||
Context::setContext('begin_' . $coroutineName, 0);
|
Context::setContext('begin_' . $coroutineName, 0, $coroutineId);
|
||||||
}
|
}
|
||||||
if (Context::getContext('begin_' . $coroutineName) === 0) {
|
if (Context::getContext('begin_' . $coroutineName, $coroutineId) === 0) {
|
||||||
$connection = Context::getContext($coroutineName);
|
$connection = Context::getContext($coroutineName);
|
||||||
if ($connection instanceof PDO && !$connection->inTransaction()) {
|
if ($connection instanceof PDO && !$connection->inTransaction()) {
|
||||||
$connection->beginTransaction();
|
$connection->beginTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context::autoIncr('begin_' . $coroutineName);
|
Context::autoIncr('begin_' . $coroutineName, $coroutineId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,10 +81,10 @@ class Connection extends Pool
|
|||||||
public function commit($coroutineName)
|
public function commit($coroutineName)
|
||||||
{
|
{
|
||||||
[$coroutineId, $coroutineName] = $this->getIndex($coroutineName, true);
|
[$coroutineId, $coroutineName] = $this->getIndex($coroutineName, true);
|
||||||
if (!Context::hasContext('begin_' . $coroutineName)) {
|
if (!Context::hasContext('begin_' . $coroutineName, $coroutineId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Context::autoDecr('begin_' . $coroutineName) > 0) {
|
if (Context::autoDecr('begin_' . $coroutineName, $coroutineId) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$connection = Context::getContext($coroutineName);
|
$connection = Context::getContext($coroutineName);
|
||||||
@@ -93,7 +93,7 @@ class Connection extends Pool
|
|||||||
$this->info('connection commit.');
|
$this->info('connection commit.');
|
||||||
$connection->commit();
|
$connection->commit();
|
||||||
}
|
}
|
||||||
Context::setContext('begin_' . $coroutineName, 0);
|
Context::setContext('begin_' . $coroutineName, 0, $coroutineId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,10 +123,10 @@ class Connection extends Pool
|
|||||||
public function rollback($coroutineName)
|
public function rollback($coroutineName)
|
||||||
{
|
{
|
||||||
[$coroutineId, $coroutineName] = $this->getIndex($coroutineName, true);
|
[$coroutineId, $coroutineName] = $this->getIndex($coroutineName, true);
|
||||||
if (!Context::hasContext('begin_' . $coroutineName)) {
|
if (!Context::hasContext('begin_' . $coroutineName, $coroutineId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Context::autoDecr('begin_' . $coroutineName) > 0) {
|
if (Context::autoDecr('begin_' . $coroutineName, $coroutineId) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($this->hasClient($coroutineName)) {
|
if ($this->hasClient($coroutineName)) {
|
||||||
@@ -137,7 +137,7 @@ class Connection extends Pool
|
|||||||
$connection->rollBack();
|
$connection->rollBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context::setContext('begin_' . $coroutineName, 0);
|
Context::setContext('begin_' . $coroutineName, 0, $coroutineId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ class Connection extends Pool
|
|||||||
{
|
{
|
||||||
$this->success('create db client -> ' . $config['cds'] . ':' . $this->hasCreate[$coroutineName] . ':' . $this->size($coroutineName));
|
$this->success('create db client -> ' . $config['cds'] . ':' . $this->hasCreate[$coroutineName] . ':' . $this->size($coroutineName));
|
||||||
$client = $this->createConnect($coroutineName, $config['cds'], $config['username'], $config['password']);
|
$client = $this->createConnect($coroutineName, $config['cds'], $config['username'], $config['password']);
|
||||||
if ($number = Context::getContext('begin_' . $coroutineName)) {
|
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
|
||||||
$number > 0 && $client->beginTransaction();
|
$number > 0 && $client->beginTransaction();
|
||||||
}
|
}
|
||||||
return $client;
|
return $client;
|
||||||
|
|||||||
Reference in New Issue
Block a user