Re: Pear DB problem with autoExecute

From: Date: Mon, 15 Nov 2004 19:02:15 +0000
Subject: Re: Pear DB problem with autoExecute
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15533@lists.php.net to get a copy of this message
On Mon, 15 Nov 2004 14:23:49 +0100, Achim Altmann <a.altmann@sell-by-web.de> wrote: > Hello, > > sorry for the following long code!! > > i work with a simple-class to handle my db-calls > > if i work with with all others methods in this class then works fin > but if i work with autoexecute comes an error > this error is at bottom on the message! > > No my class > > require_once("DB.php"); > class base_db_ebay > { > var $dbcon; > var $lasterror; > var $printerrors =TRUE; > > function base_db_ebay() > { > $this->connect(); > } > > function connect() > { > if(!($this->isConnected())) > { > $this->dbcon = & DB::connect(DB_DSN, true) > > . > . > . > usw. > > function isConnected() > { > if(is_object($this->dbcon) && > is_subclass_of($this->dbcon,"db_common")) > return TRUE; > return FALSE; > } > > //the update works fine > function update($updatestr, $updatearr) > { > $result = FALSE; > if($this->connect()) > { > $res = $this->dbcon->prepare($updatestr); > $res = $this->dbcon->execute($res,$updatearr); > if(DB::isError($res)) > { > $this->setLastError($res); > } > elseif($res === DB_OK) > { > $result = $this->dbcon->affectedRows(); > } > return $result; > } > > // und now my problem-section > function autoinsert($tableName,$tableFields,$querytype) > if($this->connect()) > { > $result > =$this->$dbcon->autoExecute($tableName,$tableFields, $querytype); > if (DB::isError($result)) { > die($sth->getMessage()); > } > } > } > > } > > if i call autoinsert > > with > $DB_con = &new base_db_ebay(); > > $DB_con->autoinsert($tableName="mytable",$arrOrder,'DB_AUTOQUERY_INSERT' > ); > > then comes > > Call to a member function autoExecute() on a non-object in > > i couldn't understood this > if i call all other methos then works fine > if i call autoexecute from an other script > directly like > > $table_name = 'user'; > $table_fields = array('id', 'name', 'country'); > > $sth = $db->autoPrepare($table_name, $table_fields, > DB_AUTOQUERY_INSERT); > > works also fine > > could any help > Sounds link your DB connection is failing. Try checking for DB errors. $this->dbcon = & DB::connect(DB_DSN, true); if (PEAR::isError($this->dbcon)) { die($this->dbcon->getMessage()."\n".$this->dbcon->getUserInfo()); } -- Justin Patrin

« previous php.pear.general (#15533) next »