Closed fogelito closed 5 months ago
Current implement looks correct:
$exception = new \PDOException($errorInfo[2], $errorInfo[1]);
According to PHP documentation on method PDO::errorInfo(), error information is stored in an array with the following fields included (plus few more, if needed):
0
: SQLSTATE error code (a five characters alphanumeric identifier defined in the ANSI SQL standard).1
: Driver-specific error code.2
: Driver-specific error message.So
$errorInfo[0]
: string|null$errorInfo[1]
: int|nullWe should use $errorInfo[1]
but not $errorInfo[0]
as the exception code.
You can see there is a difference between the original Exception. I get different error code value from the original PDOException.
@fogelito yep you are right. Fortunately, @NathanFreeman already got it fixed in Swoole 5.1.0 via PR #163 . Please feel free to give it a try and let us know if there is any concerns. Thanks
Thank you 👍
Hello, We have an application using PDOProxy and PDO, We have an inconsistency problem when trying to match the original PDOException error code. https://github.com/swoole/library/blob/master/src/core/Database/PDOProxy.php#L61 This is how it is now $exception = new PDOException($errorInfo[2], $errorInfo[1]); should be $exception = new PDOException($errorInfo[2], $errorInfo[0]); since the original Error code is in position 0. Thank you very much