qqq
This commit is contained in:
+21
-9
@@ -96,6 +96,7 @@ class Connection extends Component
|
|||||||
$eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
$eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
||||||
$eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
|
$eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
|
||||||
$eventProvider->on(Commit::class, [$this, 'commit'], 0);
|
$eventProvider->on(Commit::class, [$this, 'commit'], 0);
|
||||||
|
$eventProvider->on('afterRequest', [$this, 'clear']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,15 +184,7 @@ class Connection extends Component
|
|||||||
{
|
{
|
||||||
$this->storey--;
|
$this->storey--;
|
||||||
if ($this->storey == 0) {
|
if ($this->storey == 0) {
|
||||||
$pdo = Context::get($this->cds);
|
$this->clear();
|
||||||
if ($pdo === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($pdo->inTransaction()) {
|
|
||||||
$pdo->rollback();
|
|
||||||
}
|
|
||||||
$this->pool()->push($this->cds, $pdo);
|
|
||||||
Context::remove($this->cds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,6 +209,25 @@ class Connection extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function clear(): void
|
||||||
|
{
|
||||||
|
/** @var PDO $pdo */
|
||||||
|
$pdo = Context::get($this->cds);
|
||||||
|
if ($pdo === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($pdo->inTransaction()) {
|
||||||
|
$pdo->rollback();
|
||||||
|
}
|
||||||
|
$this->pool()->push($this->cds, $pdo);
|
||||||
|
Context::remove($this->cds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null $sql
|
* @param null $sql
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user