From ebf68628343cef0e339d9505445e17961712615b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 7 Apr 2023 19:00:37 +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, 12 insertions(+), 4 deletions(-) diff --git a/Command.php b/Command.php index 4545742..2f64cc4 100644 --- a/Command.php +++ b/Command.php @@ -71,7 +71,9 @@ class Command extends Component if (($prepare = $pdo->query($this->sql)) === false) { throw new Exception($pdo->errorInfo()[1]); } - $prepare->execute($this->params); + foreach ($this->params as $key => $param) { + $prepare->bindParam($key, $param); + } return $prepare->fetchAll(PDO::FETCH_ASSOC); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { @@ -94,7 +96,9 @@ class Command extends Component if (($prepare = $client->query($this->sql)) === false) { throw new Exception($client->errorInfo()[1]); } - $prepare->execute($this->params); + foreach ($this->params as $key => $param) { + $prepare->bindParam($key, $param); + } return $prepare->fetch(PDO::FETCH_ASSOC); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { @@ -117,7 +121,9 @@ class Command extends Component if (($prepare = $client->query($this->sql)) === false) { throw new Exception($client->errorInfo()[1]); } - $prepare->execute($this->params); + foreach ($this->params as $key => $param) { + $prepare->bindParam($key, $param); + } return $prepare->fetchColumn(PDO::FETCH_ASSOC); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { @@ -140,7 +146,9 @@ class Command extends Component if (($prepare = $client->query($this->sql)) === false) { throw new Exception($client->errorInfo()[1]); } - $prepare->execute($this->params); + foreach ($this->params as $key => $param) { + $prepare->bindParam($key, $param); + } return $prepare->rowCount(); } catch (\Throwable $throwable) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {