dear all ...
i have question, i've tried look at google but still can't figured out
how to do it...
i want access parent property from child object the code was like
id;
}
protected function setId($id)
{
$this->id = $id;
}
function getDB()
{
return $this->$db;
}
function setDB($db)
{
$this->db = $db;
}
public function load($id)
{
$query = "SELECT * FROM ".
constant(get_class($this)."::tableName").
" WHERE ".
constant(get_class($this)."::pkFields").
"='".$id."'";
$rs = $this->db->Execute($query);
$cObj = $rs->FetchObject(true);
return $cObj;
}
public function save($rowData)
{
$this->db->debug = true;
$query ="Select * FROM
".constant(get_class($this)."::tableName")."\n";
$res=$this->db->Execute($query);
$insertSQL = $this->db->GetInsertSQL($res,$rowData);
$res=$this->db->Execute($insertSQL);
if($res)
return true;
return false;
}
public function update($row, $id)
{
$query = "SELECT * FROM
".constant(get_class($this)."::tableName")."\n"
. "WHERE
".constant(get_class($this)."::pkFields")."='".$id."'";
$res= $this->db->Execute($query);
$updateSQL = $this->db->GetUpdateSQL($res,$row);
$db->Execute($updateSQL);
}
public function getAll($criteria='', $order='')
{
if(empty($order))
$order = constant(get_class($this)."::pkFields");
$query = "SELECT * FROM
".constant(get_class($this)."::tableName")."\n"
. $criteria
. "ORDER BY ".$order;
$row= $this->db->Execute($query);
if(!$row)
{
$this->error= $this->db->ErrorMsg();
return false;
}
return $row->getArray();
}
}
and i have this child
Execute($query);
return $res->getArray();
}
}
?>
and this is the class that called it
setDB($db); // i have another file called config that initialized the db;
$res = $obj->findWithRelation(1);
?>
but the php's said
Fatal error: Cannot access empty property...
what does it mean ?? is there another way to access "$db" that parent have ?
TIA
--
Jangan tanyakan apa yang Indonesia telah berikan pada mu
tapi bertanyalah apa yang telah engkau berikan kepada Indonesia
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GU/IT d- s: a-- C++ UL P L++ E W++ N* o-- K-
w PS Y-- PGP- t++ 5 X R++ tv b+ DI D+ G e+ h* r- z?
--END GEEK CODE BLOCK--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php