|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-15 02:36 UTC] danielc at analysisandsolutions dot com
[2005-02-15 15:43 UTC] danielc at analysisandsolutions dot com
[2005-02-17 21:14 UTC] andi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 11:00:01 2025 UTC |
Description: ------------ msql_fetch_row() and msql_fetch_array() silently drop columns that contain NULL values. It's important to retrieve all data from a row, even if it's NULL. oci8 does this just fine. While there's a comment in the msql_fetch_array() documentation to watch out for items that have NULL/0/'' values, it doesn't exactly say what the problem is and it only talks about results that have only one column. Reproduce code: --------------- $con = msql_connect(); $db = msql_select_db('ptdb', $con); msql_query('CREATE TABLE blah (i INT, c CHAR(5))', $con); msql_query("INSERT INTO blah VALUES (1, 'a')", $con); msql_query("INSERT INTO blah VALUES (2, NULL)", $con); msql_query("INSERT INTO blah VALUES (NULL, 'c')", $con); $result = msql_query('SELECT * FROM blah', $con); while ($arr = msql_fetch_array($result, MSQL_ASSOC)) { var_dump($arr); echo "\n"; } msql_query('DROP TABLE blah', $con); Expected result: ---------------- array(2) { ["i"]=> string(1) "1" ["c"]=> string(1) "a" } array(2) { ["i"]=> string(1) "2" ["c"]=> NULL } array(2) { ["a"]=> NULL ["c"]=> string(1) "c" } Actual result: -------------- array(2) { ["i"]=> string(1) "1" ["c"]=> string(1) "a" } array(1) { ["i"]=> string(1) "2" } array(1) { ["c"]=> string(1) "c" }