Skip to content

Commit c93c645

Browse files
author
rkr
committed
- Fixed, that PDO-Exceptions could contain strings as the exception-code: http://php.net/manual/en/class.exception.php#Hcom115813 (cHao's comment)
1 parent f6f2e44 commit c93c645

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Builder/QueryStatement.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ public function getStatement() {
4545
public function execute(array $params = []) {
4646
return $this->exceptionHandler(function () use ($params) {
4747
$timer = microtime(true);
48-
$response = $this->statement->execute($params);
48+
try {
49+
$response = $this->statement->execute($params);
50+
} catch (PDOException $e) {
51+
/** @link http://php.net/manual/en/class.exception.php#Hcom115813 (cHao's comment) */
52+
throw new PDOException($e->getMessage(), (int) $e->getCode());
53+
}
4954
$this->queryLoggers->log($this->query, microtime(true) - $timer);
5055
return $response;
5156
});

src/Databases/MySQL/MySQLExceptionInterpreter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class MySQLExceptionInterpreter {
1212
* @throw PDOException
1313
*/
1414
public function throwMoreConcreteException(PDOException $exception) {
15-
$code = $exception->errorInfo[1];
16-
$message = $exception->errorInfo[2];
15+
$code = (int) $exception->errorInfo[1];
16+
$message = (string) $exception->errorInfo[2];
1717
if($code === 1213) {
1818
throw new SqlDeadLockException($message, $code, $exception);
1919
}

0 commit comments

Comments
 (0)