php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #13549 Checking if query result columns have NULL values with *sql_fetch_row functions
Submitted: 2001-10-04 18:40 UTC Modified: 2004-07-26 16:02 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mlemos at acm dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.2 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-10-04 18:40 UTC] mlemos at acm dot org
What is the condition that determines that a result column has is NULL?

I thought that the array returned by mssql_fetch_row would return an unset entry for the given column position but it seems to set it with a boolean false value now.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-13 23:36 UTC] kalowsky@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.


 [2002-08-13 23:55 UTC] mlemos at acm dot org
This is not a support question.

Do your homework and make it worthy for other developers report any bugs at all.

It is not documented anywhere what is returned in the row array for result columns that returned NULL values.

Most PHP API for other databases just return an undefined value for the column position in the row array. PHP MSSQL API is not consistent with and so it seems like a bug.

If it is not a bug, document the intended behaviour.
 [2002-08-14 09:29 UTC] kalowsky@php.net
Seeing as this bug was submitted against PHP 4.0.6, and that we are now at 4.2.2 (a long ways) this is now to be considered a feature thanks to backwards compatibility.  

I haven't seen any other complaints about this functionality, nor have I heard any.  A quick search on google reveals no complaints either.  I did do my homework Mr. Lemos, so please don't turn this into a personal issue.  

If you believe that this should be documented, so be it.  Write up the bit of documentation that you believe is required, and post it inside this bug.  
 [2002-08-14 21:30 UTC] mlemos at acm dot org
There is no personal issue here. Assuming that this bug report  was was a support request just showed that you did not pay much attention to what was reported. Pay attention and test what reported as broken is what you should have done as your homework.

The issue here is that MS SQL API was modeled after MySQL API a long time ago in the PHP 3 days. By then there was no boolean type in PHP. As far as I can recall this function was not return anything then for NULL columns, just like in MySQL API which does not document this behaviour.

This problem was spotted by running regression tests that succeed in MySQL but not in MSSQL. That is why I assumed it can only be a bug, especially because it could never have returned a boolean value when it was working as expected.

Setting straight the behaviour of a function that is not completely documented is not breaking compatibility. Making it work consistently with the way it was originally based on, is the right way to solve the issue.
 [2002-08-14 21:52 UTC] kalowsky@php.net
MSSQL may have been based upont the MySQL functionality, but it is now it's on beast.  To continue thinking along the lines that the two are similiar is just a bad idea.  

The code in question by you is this:
if (Z_TYPE(result->data[result->cur_row][i]) != IS_NULL) {
/* ... snip ... */
}
else
{
    if (result_type & MSSQL_NUM)
         add_index_null(return_value, i);
    if (result_type & MSSQL_ASSOC)
         add_assoc_null(return_value, 
            result->fields[i].name);
}

As you can see, the behavior is checked based upon the IS_NULL value.  When it is decided that there is a NULL value returned, it is further checked against the two other types.  The first of which sets an add_index_null to the return_value, based upon the value of 'i'.  'i' is an integer, thus it will always have a value, at the least of zero.

That being said, if you still feel this should be more properly documented I welcome you to write that section of, paste it into this bug report, and reopen it.  

As it stands this isn't a bug, thus it shouldn't be in the bug database, and I again state: If you need help please ask on the php-general mailing list, but the bug database is not the place for support questions.    
 [2002-08-17 17:19 UTC] mlemos at acm dot org
I checked the latest version of PHP (4.2.2) and the bug is indeed gone. Since it really existed and I just reconfirmed in PHP 4.0.6 it was not bogus as you claimed. Also the fixed behaviour of mssql_fetch_row is the same as mysql_fetch_row, unlike you implied that it would be independent.

Anyway, the lack of documentation of how NULL values are returned in *sql_fetch_row functions is still lacking.

I am reopening this report so anybody with time and patience goes through all PHP database API functions that fetch query result rows like mssql_fetch_row, mysql_fetch_row, etc... be clear that columns with NULL are returned as undefined.
 [2002-08-17 23:50 UTC] kalowsky@php.net
Stop.  Pay attention to the "bug" you are reporting and read what has been said.  If you feel that the documentation covering the MSSQL module is lacking, please add to this "bug" report what you feel is sufficent.  

And yes the "bug" is invalid in the current code.  I really don't care about the past versions.  The only thing I implied is that your assumption that the two are similar is a false belief.  While they may be similiar now (or were), it does not stand to reason that they will stay that way.  
 [2002-08-19 09:15 UTC] mlemos at acm dot org
My last paragraph of the previous comment says it all. What needs to be done is to go through all functions like mysql_fetch_row that all PHP database API support and include that comment regarding how to determine if a column contains a NULL, using proper English.
 [2004-07-26 16:02 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

I checked MSSQL, MySQL, Oci8 and PgSQL and all sets null value for NULL fields now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 19:01:28 2024 UTC