Mantis - Quercus
Viewing Issue Advanced Details
3310 block always 01-30-09 17:18 10-07-10 07:15
koreth  
 
normal  
assigned 4.0.0  
no change required  
none    
none  
0003310: mysql_fetch_assoc() discards data types
mysql_fetch_assoc() returns an array of string values even when the database columns are numeric. This messes up some equality tests because, e.g., 0 == null but '0' != null.

Patch attached.
 patch.txt [^] (1,187 bytes) 01-30-09 17:18

Notes
(0003794)
nam   
02-02-09 15:49   
The original behavior should be correct because it matches PHP's.


Test Case
=========
$link = mysql_connect();
mysql_select_db("test");

mysql_query("DROP TABLE test");
mysql_query("CREATE TABLE test (id INTEGER, data DOUBLE)");
mysql_query("INSERT INTO test VALUES (123, 4.56)");
mysql_query("INSERT INTO test VALUES (0, 0.0)");

$result = mysql_query("SELECT * FROM test");

while ($line = mysql_fetch_assoc($result)) {
  var_dump($line);
}


Expected Output
===============
array(2) {
  ["id"]=>
  string(3) "123"
  ["data"]=>
  string(4) "4.56"
}
array(2) {
  ["id"]=>
  string(1) "0"
  ["data"]=>
  string(3) "0"
}