php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gildseth at start dot no
New email:
PHP Version: OS:

 

 [2003-08-10 10:44 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-10 13:32 UTC] 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-18 07:09 UTC] 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-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] cox@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC