From: danielc at analysisandsolutions dot com
Operating system: NetBSD 2.0
PHP version: 5CVS-2005-02-13 (dev)
PHP Bug Type: mSQL related
Bug description: msql_fetch_row() and msql_fetch_array() dropping columns with
NULL values
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"
}
--
Edit bug report at http://bugs.php.net/?id=31960&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31960&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31960&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31960&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31960&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31960&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31960&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31960&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31960&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31960&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31960&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31960&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31960&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31960&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31960&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31960&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31960&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31960&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31960&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31960&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31960&r=mysqlcfg