ID: 43967 User updated by: emilien dot colotte at free dot fr Reported By: emilien dot colotte at free dot fr -Status: Open +Status: Closed Bug Type: PDO related Operating System: Vista PHP Version: 5.2.5 New Comment:
This is not a bug. Previous Comments: ------------------------------------------------------------------------ [2008-01-29 15:29:52] emilien dot colotte at free dot fr Description: ------------ I made a simple sum query on a table column. The column contains some integer values and some null values. By executing the query throught the PDO MySQL driver, the result is wrong. By using the classic mysql library in PHP, the result is ok. I think there is a bug in PDO MySQL driver. More informations: - MySQL Version: 5.0.45 - PHP version: 5.2.4 Reproduce code: --------------- CREATE TABLE `TEST` ( `ID_TEST` int(10) NOT NULL AUTO_INCREMENT, `VALUE` int(10) default NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; INSERT INTO TEST (ID_TEST, VALUE) VALUES (1, NULL); INSERT INTO TEST (ID_TEST, VALUE) VALUES (2, -1); SELECT SUM(VALUE) AS TOTAL FROM TEST; Expected result: ---------------- The value returned by the query must be -1. Actual result: -------------- By executing the query from PDO, the value returned is NULL By executing the query from MySQL library, the value returned is -1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43967&edit=1
