Bug #54978 [Opn->Fbk]: mysql_query() returns true with a SELECT statement
Edit report at https://bugs.php.net/bug.php?id=54978&edit=1
ID: 54978
Updated by: uw@php.net
Reported by: radu dot dineiu at gmail dot com
Summary: mysql_query() returns true with a SELECT statement
-Status: Open
+Status: Feedback
Type: Bug
Package: MySQL related
Operating System: Any
PHP Version: 5.3.6
-Assigned To:
+Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
Are you using libmysql, if so, which version? Can you reproduce with mysqlnd?
And, yes, looks like we need the patch. I wonder if its libmysql version dependent.
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2011-06-02 17:38:28] radu dot dineiu at gmail dot com
Description:
------------
This doesn't happen often, but it does happen sometimes when the database server
interrupts the connection during a query. Seems to be related to the fact that
libmysqlclient's mysql_query() may return success, even if an error occurred, as
described at:
http://dev.mysql.com/doc/refman/5.5/en/null-mysql-store-result.html
Test script:
---------------
$resource = mysql_query('SELECT test FROM test');
if ($resource === true) {
throw new Exception('mysql_query() returned true for SELECT');
}
Expected result:
----------------
An exception should not be thrown, because the documentation for mysql_query() at
php.net clearly states that a SELECT query will only ever return false or a
resource.
Actual result:
--------------
An exception is thrown, because mysql_query() returns true with a SELECT query.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54978&edit=1
Thread (4 messages)