php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12008 mysql_fetch_* inconsistent with MySQL C API
Submitted: 2001-07-10 09:08 UTC Modified: 2001-07-10 15:29 UTC
From: strougatski at ea-ratings dot ru Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.6 OS: RedHat 6.2
Private report: No CVE-ID: None
 [2001-07-10 09:08 UTC] strougatski at ea-ratings dot ru
The handling of NULL values in mysql_fetch_* function seems to be inconsistent with MySQL C API:
in C, mysql_fetch_row() would put nil values in the row array if corresponding value in the select statement is NULL.
In PHP it seems, as dicussed on mysql_fetch_array() page, the NULL values would not be stored in the array at all.
This poses some problems when migrating from C to PHP. Would it be possible to introduce another function that would be consistent with MySQL C API? 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-10 09:14 UTC] zeev@php.net
fetch_array, in recent versions (4.0.6 inclusive) should actrually populate NULL values in the array.  Are you sure you tested it with 4.0.6?  How did you arrive to the conlusion they're not there?

 [2001-07-10 13:08 UTC] brianlmoon@php.net
In PHP setting a var to NULL in fact destroys that var so it is not currently possible to have an elelment in an array that has a NULL value.

On a side note, if you read the MySQL optimization docs, you will find they reccommend you never use NULL fields.

Brian.
 [2001-07-10 15:29 UTC] jeroen@php.net
About not using NULL values: It is not efficient to use PHP, use C, or even better: assembler if you want the most efficient dynamic website.
IMHO, null values are incredibly useful. As is PHP, by the way :)

And arrays *do* support NULL values. The only point is that isset($a_var_containing_null) returns false. But with foreach you will go over the value. With var_dump on such an array, you will see the null-values.

Zeev: do you know since when it does / doesn't work? Then I'll note it in the docs.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 16:01:29 2024 UTC