php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44270 $mysqli->info is NULL, not an empty string, for "not supported situations"
Submitted: 2008-02-27 17:55 UTC Modified: 2008-11-10 01:00 UTC
Votes:3
Avg. Score:3.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: stein at visibone dot com Assigned: andrey (profile)
Status: No Feedback Package: MySQLi related
PHP Version: 5.2.5 OS: *
Private report: No CVE-ID: None
 [2008-02-27 17:55 UTC] stein at visibone dot com
Description:
------------
$mysqli->info is NULL instead of empty string for "not supported situations" (i.e. queries other than multi-row INSERT, LOAD, ALTER, UPDATE)  The procedural mysqli_info() does return the empty string, as documented.


Reproduce code:
---------------
Query:  'INSERT INTO t (id) VALUES (1),(2),(3)'
mysqli_info():  'Records: 3  Duplicates: 0  Warnings: 0'
$mysqli->info:  'Records: 3  Duplicates: 0  Warnings: 0'

Query:  'INSERT INTO t (id) VALUES (9)'
mysqli_info():  ''
$mysqli->info:  NULL


Expected result:
----------------
(see above)

Actual result:
--------------
the object oriented property $mysqli->info should be the empty string after "not supported situations", e.g. a single-row insert.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-04 13:45 UTC] felipe@php.net
Hi Johannes/Ulf

Whereas the documentation says "empty string" for each string property, i guess that could be modified the macro responsible for that.

http://felipe.ath.cx/diff/bug44270.diff

What do you think? :)

 [2008-03-04 15:11 UTC] uwendel at mysql dot com
Interesting question and good point. In real life only few people might notice the difference and cast the return value to string, but good question...

Please don't commit the change. I wonder if there are more such tiny differences. For example, I wonder if my mysqli_info.phpt test is correct. Let me check in more detail first before we change anything.

Ulf
 [2008-07-15 16:05 UTC] uw@php.net
Bug - I'll modify mysqi_info.phpt to cover this detail.
 [2008-07-15 16:06 UTC] uw@php.net
... and of course: free to fix for whoever comes first 
 [2008-07-24 12:08 UTC] uw@php.net
The more I think about it, the better I like NULL. NULL will be used on the C-level, under the hood. false gets used in ext/mysql. And both NULL and false have a different meaning than empty string. An empty string means that there is some information - even if the string is empty. NULL means that no information is available.

In any case the procedural and OO interface should return the same value. Comments?

I don't mind the PHP manual much as its a very minor change which most people will not notice as NULL == '' is true.
 [2008-07-25 17:40 UTC] stein at visibone dot com
uw I can mostly buy what you're selling.  Firstly, the doc should not lie, so changing the doc, or changing the code works for me.

Secondarily, consistency is good, other things being equal.  mysqli_info() should fail the same way as $mysqli->info 

I still slightly prefer the empty string because it fails a little more gently, and there are much less ill-mannered ways of checking for failure than comparing this field with NULL or ''.  But I defer to whatever noble soul does the actual work.
 [2008-11-02 13:34 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC