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

From: Date: Wed, 26 Jan 2022 13:46:50 +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-239296@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8004 Author: etkaar ### Description While the MySQL error itself is expected (caused by the boolean value _false_ for the second column), the error message _Invalid datetime format_ is misleading since this has nothing to do with any date(time) types. ```php <?php $pdo = new PDO('mysql:host=localhost;dbname=database_name;charset=utf8mb4', 'username', '...'); $handle = $pdo->prepare("INSERT INTO test (true, false) VALUES (?, ?)"); $handle->execute([true, false]); ``` Resulted in this output: ``` Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column test.test.false [...] ``` # SQL Structure ``` CREATE TABLE test ( id int(11) NOT NULL, true tinyint(1) UNSIGNED NOT NULL, false tinyint(1) UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE test ADD PRIMARY KEY (id); ALTER TABLE test MODIFY id int(11) NOT NULL AUTO_INCREMENT; ``` ### PHP Version PHP 8.0.14 ### Operating System _No response_

« previous php.bugs (#239296) next »