From 9bf84533948a96eacd2624e26d8778cf63bc9105 Mon Sep 17 00:00:00 2001 From: Yurun Date: Mon, 6 May 2024 10:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20PDO=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=A0=81=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Db/Drivers/TPdoDriver.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Db/Drivers/TPdoDriver.php b/src/Db/Drivers/TPdoDriver.php index 2c1d1553e..88d5223f6 100644 --- a/src/Db/Drivers/TPdoDriver.php +++ b/src/Db/Drivers/TPdoDriver.php @@ -327,12 +327,12 @@ public function exec(string $sql): int if (false === $result) { $errorCode = $this->errorCode(); - $errorInfo = $this->errorInfo(); - if ($this->checkCodeIsOffline($errorCode)) + $errorInfo = $this->instance->errorInfo(); + if ($this->checkCodeIsOffline($errorInfo[0], $errorInfo[1])) { $this->close(); } - throw new DbException('SQL exec error [' . $errorCode . '] ' . $errorInfo . \PHP_EOL . 'sql: ' . $sql . \PHP_EOL); + throw new DbException('SQL exec error [' . $errorCode . '] ' . $this->errorInfo() . \PHP_EOL . 'sql: ' . $sql . \PHP_EOL); } } catch (\PDOException $e) @@ -399,12 +399,12 @@ public function prepare(string $sql, array $driverOptions = []): IStatement if (false === $lastStmt) { $errorCode = $this->errorCode(); - $errorInfo = $this->errorInfo(); - if ($this->checkCodeIsOffline($errorCode)) + $errorInfo = $this->instance->errorInfo(); + if ($this->checkCodeIsOffline($errorInfo[0], $errorInfo[1])) { $this->close(); } - throw new DbException('SQL prepare error [' . $errorCode . '] ' . $errorInfo . \PHP_EOL . 'sql: ' . $sql . \PHP_EOL); + throw new DbException('SQL prepare error [' . $errorCode . '] ' . $this->errorInfo() . \PHP_EOL . 'sql: ' . $sql . \PHP_EOL); } $this->lastStmt = $lastStmt; $stmt = BeanFactory::newInstance($this->statementClass, $this, $lastStmt); @@ -439,12 +439,12 @@ public function query(string $sql): IStatement if (false === $lastStmt) { $errorCode = $this->errorCode(); - $errorInfo = $this->errorInfo(); - if ($this->checkCodeIsOffline($errorCode)) + $errorInfo = $this->instance->errorInfo(); + if ($this->checkCodeIsOffline($errorInfo[0], $errorInfo[1])) { $this->close(); } - throw new DbException('SQL query error [' . $errorCode . '] ' . $errorInfo . \PHP_EOL . 'sql: ' . $sql . \PHP_EOL); + throw new DbException('SQL query error [' . $errorCode . '] ' . $this->errorInfo() . \PHP_EOL . 'sql: ' . $sql . \PHP_EOL); } $this->lastStmt = $lastStmt; }