|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25003 DB bums out with a "Call to member function on a non-object"
Submitted: 2003-08-10 10:44 UTC Modified: 2003-08-28 09:23 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: gildseth at start dot no Assigned: cox (profile)
Status: Closed Package: PEAR related
PHP Version: 4.3.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
33 + 11 = ?
Subscribe to this entry?

 [2003-08-10 10:44 UTC] gildseth at start dot no
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-10 13:32 UTC] gildseth at start dot no
An example which triggers the bug:

define('DB_CONNECT_STR', 'mysql://username:password@hostname/database');
$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-18 07:09 UTC]
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-18 07:15 UTC] 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-28 09:23 UTC]
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
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Jan 28 20:03:33 2022 UTC