From 72cfba6a5d0dad6773de9dcb1d6161ebeb3ae50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 20 Sep 2022 18:33:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Connection.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Connection.php b/Connection.php index 8004781..8ec87df 100644 --- a/Connection.php +++ b/Connection.php @@ -199,7 +199,7 @@ class Connection extends Component public function getPdo(): PDO { if (!Context::hasContext('master:client')) { - Context::setContext('master:client', $this->getMasterClient()); + Context::setContext('master:client', $this->getMasterClient()); } return Context::getContext('master:client'); } @@ -260,14 +260,14 @@ class Connection extends Component * 回收链接 * @throws */ - public function release(PDO $pdo, $isMaster) + public function release(PDO $pdo, bool $isMaster) { $connections = $this->connection; + $cds = ($this->slaveConfig['cds'] ?? $this->cds) . ($isMaster ? 'master' : 'slave'); if (!$isMaster) { - $cds = $this->slaveConfig['cds'] ?? $this->cds; $connections->addItem($cds, $pdo); } else if (!$pdo->inTransaction()) { - $connections->addItem($this->cds, $pdo); + $connections->addItem($cds, $pdo); } }