From ffc8cd7a33dbf4a25bc6c7c639bec09aa8f0e14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 5 Apr 2023 20:27:00 +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 --- Command.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Command.php b/Command.php index 1d9a3bc..ba7164a 100644 --- a/Command.php +++ b/Command.php @@ -72,9 +72,7 @@ class Command extends Component if ($prepare === false || $prepare->execute($this->params) === false) { throw new Exception(($prepare ?? $pdo)->errorInfo()[1]); } - $count = $prepare->fetchAll(PDO::FETCH_ASSOC); - $prepare->closeCursor(); - return $count; + return $prepare->fetchAll(PDO::FETCH_ASSOC); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->all(); @@ -97,9 +95,7 @@ class Command extends Component if ($prepare === false || $prepare->execute($this->params) === false) { throw new Exception(($prepare ?? $pdo)->errorInfo()[1]); } - $count = $prepare->fetch(PDO::FETCH_ASSOC); - $prepare->closeCursor(); - return $count; + return $prepare->fetch(PDO::FETCH_ASSOC); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->one(); @@ -122,9 +118,7 @@ class Command extends Component if ($prepare === false || $prepare->execute($this->params) === false) { throw new Exception(($prepare ?? $pdo)->errorInfo()[1]); } - $count = $prepare->fetchColumn(PDO::FETCH_ASSOC); - $prepare->closeCursor(); - return $count; + return $prepare->fetchColumn(PDO::FETCH_ASSOC); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->fetchColumn(); @@ -147,9 +141,7 @@ class Command extends Component if ($prepare === false || $prepare->execute($this->params) === false) { throw new Exception(($prepare ?? $pdo)->errorInfo()[1]); } - $count = $prepare->rowCount(); - $prepare->closeCursor(); - return $count; + return $prepare->rowCount(); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->rowCount();