我有以下代码
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";
}
}
它可以正常工作,但是当我从子类调用此更新函数时,子类会出错,如下所示
class DemoApplication extends Application
{
callParent()
{
$this->update($this->db);
}
}
当我使用这种方式时,它会给出错误Fatal error: Call to a member function query() on a non-object in