Skip to content

Commit

Permalink
修复 PDO 错误码判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed May 6, 2024
1 parent afb2950 commit 9bf8453
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Db/Drivers/TPdoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 9bf8453

Please sign in to comment.