[php-src] Issue #11035: pdo_mysql fetches UNSIGNED INT values as strings when using DISTINCT with a MySQL (5.7.39) built-in function

From: Date: Fri, 07 Apr 2023 16:44:12 +0000
Subject: [php-src] Issue #11035: pdo_mysql fetches UNSIGNED INT values as strings when using DISTINCT with a MySQL (5.7.39) built-in function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244144@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11035 Author: bglover ### Description First, create a basic table as an example: ```sql CREATE TABLE t (id INT UNSIGNED); ``` Populate it with a test value: ```sql INSERT INTO t VALUES (1); ``` Then using simple PDO (change host, user, pas and dbname to suite your env): ```php <?php $db = new \PDO('mysql:host=localhost;dbname=test', 'user', 'pass'); $stmt = $db->prepare('SELECT DISTINCT IFNULL(id, 0) FROM t'); $stmt->execute(); var_dump($stmt->fetchAll()); ``` Resulted in this output: ``` array(1) { [0]=> array(2) { ["IFNULL(id, 0)"]=> string(1) "1" [0]=> string(1) "1" } } ``` But I expected this output instead: ``` array(1) { [0]=> array(2) { ["IFNULL(id, 0)"]=> int(1) [0]=> int(1) } } ``` Change the type of id to INT SIGNED via ```sql ALTER TABLE t MODIFY id INT; ``` Will result in the expected output ### PHP Version PHP 8.0, 8.1, 8.2 ### Operating System _No response_

« previous php.bugs (#244144) next »