#25003 [Com]: DB bums out with a "Call to member function on a non-object"

From: Date: Mon, 18 Aug 2003 12:15:44 +0000
Subject: #25003 [Com]: 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-19974@lists.php.net to get a copy of this message
ID: 25003 Comment by: alan at akbkhome dot com Reported By: gildseth at start dot no Status: Assigned Bug Type: PEAR related Operating System: Linux PHP Version: 4.3.1 Assigned To: cox New Comment: 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) Previous Comments: ------------------------------------------------------------------------ [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

« previous php.pear.dev (#19974) next »