From: adam at omega dot org dot uk
Operating system: Linux
PHP version: 5.2.4RC1
PHP Bug Type: Unknown/Other Function
Bug description: mysql_query or die(): unusual behaviour
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 bug report at http://bugs.php.net/?id=42278&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42278&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42278&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42278&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42278&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42278&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42278&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42278&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42278&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42278&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42278&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42278&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42278&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42278&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42278&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42278&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42278&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42278&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42278&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42278&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42278&r=mysqlcfg