[php-src] Issue #8004: Misleading PDO error message ‹Invalid datetime format›

From: Date: Wed, 26 Jan 2022 15:50:24 +0000
Subject: [php-src] Issue #8004: Misleading PDO error message ‹Invalid datetime format›
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239303@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8004 Comment Author: kamil-tekiela Ahh ok, let me explain this better. When PHP (mysqlnd to be exact) receives response containing an error from the database server, it arrives with the following pieces of information: ``` Error message: "Incorrect integer value: '' for column test.test.false at row 1" Error number: 1366 SQLSTATE: 22007 ``` Now, it's a job of the client (PDO in this instance) to present the error message in the form of an exception. PDO has chosen to follow the following format for its exception messages: ``` SQLSTATE[<SQLSTATE>]: <SQLSTATE description>: <Error number> <Error message> ``` Other clients, such as MySQL console, have selected a different format. For MySQL console it is: ``` ERROR <Error number> (<SQLSTATE>): <Error message> ``` As you can see the format chosen is entirely different. MySQL console decided to not map the SQLSTATE to its description. PDO does. It's not an incorrect behaviour, it's just a different presentation method. The information being presented is the same and the error message is exactly as it comes from the database server.

« previous php.bugs (#239303) next »