From e06c04a5bb5a759dbe9fe5f61fc370c24ad27a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 24 Aug 2023 11:55:43 +0800 Subject: [PATCH] qqq --- Command.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Command.php b/Command.php index e4cdad9..c2332e7 100644 --- a/Command.php +++ b/Command.php @@ -77,8 +77,8 @@ class Command extends Component */ public function all(): bool|array { - $client = $this->connection->getConnection(); try { + $client = $this->connection->getConnection(); if (($prepare = $client->prepare($this->sql)) === false) { throw new Exception($client->errorInfo()[1]); } @@ -91,7 +91,9 @@ class Command extends Component } return $result; } finally { - $this->connection->release($client); + if (isset($client)) { + $this->connection->release($client); + } } } @@ -101,8 +103,8 @@ class Command extends Component */ public function one(): null|bool|array { - $client = $this->connection->getConnection(); try { + $client = $this->connection->getConnection(); if (($prepare = $client->prepare($this->sql)) === false) { throw new Exception($client->errorInfo()[1]); } @@ -115,7 +117,9 @@ class Command extends Component } return $result; } finally { - $this->connection->release($client); + if (isset($client)) { + $this->connection->release($client); + } } } @@ -125,8 +129,8 @@ class Command extends Component */ public function fetchColumn(): mixed { - $client = $this->connection->getConnection(); try { + $client = $this->connection->getConnection(); if (($prepare = $client->prepare($this->sql)) === false) { throw new Exception($client->errorInfo()[1]); } @@ -139,7 +143,9 @@ class Command extends Component } return $result; } finally { - $this->connection->release($client); + if (isset($client)) { + $this->connection->release($client); + } } } @@ -161,8 +167,8 @@ class Command extends Component */ private function _execute(): bool|int { - $client = $this->connection->getConnection(); try { + $client = $this->connection->getConnection(); if (($prepare = $client->prepare($this->sql)) === false) { throw new Exception($client->errorInfo()[1]); } @@ -182,7 +188,9 @@ class Command extends Component } return $result; } finally { - $this->connection->release($client); + if (isset($client)) { + $this->connection->release($client); + } } }