[php-src] Issue #8795: PDO MySQL returns php value type "string" for column type "YEAR"

From: Date: Wed, 15 Jun 2022 21:16:56 +0000
Subject: [php-src] Issue #8795: PDO MySQL returns php value type "string" for column type "YEAR"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241741@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8795 Author: dortort ### Description The following code: ```php <?php /** * Given: * CREATE TABLE t ( * y year(4) DEFAULT NULL, * m tinyint(3) DEFAULT NULL * ) ENGINE=InnoDB DEFAULT CHARSET=utf8 * INSERT INTO t VALUES (2001, 11); */ $pdo = new PDO($dsn, null, null, [ PDO::ATTR_EMULATE_PREPARES => false ]); var_dump($pdo->query("SELECT * FROM t")->fetchAll(PDO::FETCH_ASSOC)); ``` Resulted in this output: ``` array(1) { [0]=> array(2) { ["y"]=> string(4) "2001" ["m"]=> int(11) } } ``` But I expected this output instead: ``` array(1) { [0]=> array(2) { ["y"]=> int(2001) ["m"]=> int(11) } } ``` This breaking change occurs between PHP v8.0 & v8.1. ### PHP Version 8.1.6 ### Operating System Alpine 10.2

« previous php.bugs (#241741) next »