From 685a0d72b27fa883fe983deee8014582b9e3feaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 2 Apr 2023 01:26:10 +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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Command.php b/Command.php index e956635..b7b569b 100644 --- a/Command.php +++ b/Command.php @@ -66,7 +66,8 @@ class Command extends Component public function all(): ?array { [$pdo, $statement] = $this->search(); - + + $statement->execute($this->params); $data = $statement->fetchAll(PDO::FETCH_ASSOC); $this->db->release($pdo); @@ -82,6 +83,7 @@ class Command extends Component { [$pdo, $statement] = $this->search(); + $statement->execute($this->params); $data = $statement->fetch(PDO::FETCH_ASSOC); $this->db->release($pdo); @@ -96,7 +98,8 @@ class Command extends Component public function fetchColumn(): mixed { [$pdo, $statement] = $this->search(); - + + $statement->execute($this->params); $data = $statement->fetchColumn(PDO::FETCH_ASSOC); $this->db->release($pdo); @@ -111,7 +114,8 @@ class Command extends Component public function rowCount(): ?int { [$pdo, $statement] = $this->search(); - + + $statement->execute($this->params); $data = $statement->rowCount(); $this->db->release($pdo); @@ -170,12 +174,9 @@ class Command extends Component { $pdo = $this->db->getSlaveClient(); try { - if (($statement = $pdo->query($this->sql)) === false) { + if (($statement = $pdo->prepare($this->sql)) === false) { throw new Exception($pdo->errorInfo()[1]); } - foreach ($this->params as $key => $param) { - $statement->bindValue($key, $param); - } return [$pdo, $statement]; } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {