i have the following code
class Application
{
protected $db;
public function getDBChange(database $db)
{
$this->db =& $db;
$this->update($db);
}
protected function update($db)
{
$this->db=& $db;
echo "\nServer - update- IN";
$SQL = "UPDATE `version` SET app_ver='1.0.6'";
if (!$this->db->query($SQL))
{
echo "\nDatabase Error.";
}
echo "\nServer - update- OUT";
}
}
it works properly but when I called this update function from a child class it gives error the child class as follow
class DemoApplication extends Application
{
callParent()
{
$this->update($this->db);
}
}
when i use this way it gives Error Fatal error: Call to a member function query() on a non-object in
That’s because
$dbdoesn’t have aquery()method. Is$this->dbactually set and of an object that has aquery()method?Do some debugging: