Pear DB problem with autoExecute
| From: | Achim Altmann | Date: | Mon, 15 Nov 2004 13:23:49 +0000 |
| Subject: | Pear DB problem with autoExecute | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-15511@lists.php.net to get a copy of this message | ||
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 best regards Achim