This commit is contained in:
2023-08-24 14:13:22 +08:00
parent 853f23bb3d
commit 6cb5899fe1
+6 -6
View File
@@ -202,7 +202,7 @@ class Connection extends Component
if ($this->storey == 0) { if ($this->storey == 0) {
/** @var PDO $pdo */ /** @var PDO $pdo */
$pdo = Context::get($this->cds); $pdo = Context::get($this->cds);
if ($pdo instanceof PDO && !$pdo->inTransaction()) { if ($pdo instanceof PDO && !$this->inTransaction()) {
$pdo->beginTransaction(); $pdo->beginTransaction();
} }
} }
@@ -220,7 +220,7 @@ class Connection extends Component
$pdo = Context::get($this->cds); $pdo = Context::get($this->cds);
if ($pdo === null) { if ($pdo === null) {
$pdo = $this->getNormalClientHealth(); $pdo = $this->getNormalClientHealth();
if ($this->storey > 0 && !$pdo->inTransaction()) { if ($this->storey > 0 && !$this->inTransaction()) {
$pdo->beginTransaction(); $pdo->beginTransaction();
} }
Context::set($this->cds, $pdo); Context::set($this->cds, $pdo);
@@ -263,7 +263,7 @@ class Connection extends Component
if ($pdo === null) { if ($pdo === null) {
return; return;
} }
if ($pdo->inTransaction()) { if ($this->inTransaction()) {
$pdo->commit(); $pdo->commit();
} }
$this->pool()->push($this->cds, [$pdo, time()]); $this->pool()->push($this->cds, [$pdo, time()]);
@@ -283,7 +283,7 @@ class Connection extends Component
if ($pdo === null) { if ($pdo === null) {
return; return;
} }
if ($pdo->inTransaction()) { if ($this->inTransaction()) {
$pdo->rollback(); $pdo->rollback();
} }
$this->pool()->push($this->cds, [$pdo, time()]); $this->pool()->push($this->cds, [$pdo, time()]);
@@ -310,8 +310,8 @@ class Connection extends Component
*/ */
public function release(PDO $PDO): void public function release(PDO $PDO): void
{ {
file_put_contents('php://output', '回收PDO连接. inTransaction ' . (int)$PDO->inTransaction() . $this->cds, FILE_APPEND); file_put_contents('php://output', '回收PDO连接. inTransaction ' . (int)$this->inTransaction() . $this->cds, FILE_APPEND);
if ($PDO->inTransaction()) { if ($this->inTransaction()) {
return; return;
} }
file_put_contents('php://output', '回收PDO连接.' . $this->cds, FILE_APPEND); file_put_contents('php://output', '回收PDO连接.' . $this->cds, FILE_APPEND);