#42278 [Opn->Bgs]: mysql_query or die(): unusual behaviour
| From: | johannes@php.net | Date: | Sun, 12 Aug 2007 15:31:36 +0000 |
| Subject: | #42278 [Opn->Bgs]: mysql_query or die(): unusual behaviour | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116002@lists.php.net to get a copy of this message | ||
ID: 42278
Updated by: johannes@php.net
Reported By: adam at omega dot org dot uk
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Linux
PHP Version: 5.2.4RC1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The operator "or" is a boolean operator therefore you're returning a
boolean result of that operation.
Previous Comments:
------------------------------------------------------------------------
[2007-08-12 14:57:26] adam at omega dot org dot uk
Description:
------------
There is some unusual behaviour in the attached function. When a new
Database object is created, and a query called by:
$result = $this->db_connection->query($valid_sql_query);
Different results will occur, depending on the layout of the
Database::query method.
PHP version: 5.2.2
I do not own the webserver, and I doubt that they will be willing to
upgrade to an unstable version to test it.
Reproduce code:
---------------
Works:
class Database{
function query($_sql)
{
$q = mysql_query($_sql)or die("Invalid Query: $_sql <br />" .
mysql_error());
return $q;
}
}
---
Returns true:
class Database{
function query($_sql)
{
return mysql_query($_sql) or die("Invalid Query: $_sql <br />"
. mysql_error());
}
}
---
Works:
class Database{
function query($_sql)
{
return mysql_query($_sql);
}
}
Expected result:
----------------
In all cases, a mysql resource should be returned.
Actual result:
--------------
In cases 1 and 3 a mysql result is returned. In case 2, the function
simply returns true.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42278&edit=1