|  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
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: stein at visibone dot com
New email:
PHP Version: OS:


 [2008-02-27 17:55 UTC] stein at visibone dot com
$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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-04 13:45 UTC]
Hi Johannes/Ulf

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

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.

 [2008-07-15 16:05 UTC]
Bug - I'll modify mysqi_info.phpt to cover this detail.
 [2008-07-15 16:06 UTC]
... and of course: free to fix for whoever comes first 
 [2008-07-24 12:08 UTC]
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]
Please try using this CVS snapshot:
For Windows:

 [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: Sun Jun 16 03:01:28 2024 UTC