#25003 [Asn->Csd]: DB bums out with a "Call to member function on a non-object"
| From: | cox@php.net | Date: | Thu, 28 Aug 2003 14:23:29 +0000 |
| Subject: | #25003 [Asn->Csd]: DB bums out with a "Call to member function on a non-object" | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20750@lists.php.net to get a copy of this message | ||
ID: 25003
Updated by: cox@php.net
Reported By: gildseth at start dot no
-Status: Assigned
+Status: Closed
Bug Type: PEAR related
Operating System: Linux
PHP Version: 4.3.1
Assigned To: cox
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2003-08-18 07:15:44] alan at akbkhome dot com
getAll checks for pear Error, however most databases just return DB_OK
for update/alter queries.. so that check in getAll is incorrect.
I guess just adding
if ($ret == DB_OK) {
return DB_OK;
}
should fix it.
(similar comment in the postgres explain bug)
------------------------------------------------------------------------
[2003-08-18 07:09:48] nicos@php.net
It looks we verify if the query is fine with DB::isError. and it looks
a big problem with isError, it looks we thought it returns true on
error but in fact it returns false...
Need feedback from cox/ssb please.
------------------------------------------------------------------------
[2003-08-10 13:32:40] gildseth at start dot no
An example which triggers the bug:
<?PHP
define('DB_CONNECT_STR',
'mysql://username:password@hostname/database');
require_once('DB.php');
$pearDB = DB::connect(DB_CONNECT_STR);
$pearDB->getAll('DELETE FROM test WHERE id=4');
/*
CREATE TABLE test (id int(11) default NULL); INSERT INTO test
VALUES(4);
*/
?>
------------------------------------------------------------------------
[2003-08-10 10:44:05] gildseth at start dot no
Description:
------------
I accidentally passed a DELETE query to DB::getAll, and DB fell over:
Fatal error: Call to a member function on a non-object in
/usr/local/lib/php/DB/common.php on line 1166
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25003&edit=1