Inheritance Problem/Bug
Posted: Wed Jun 10, 2009 1:09 am
Hey,
Could someone confirm if the problem is with my logic or not.
I have a class called System. One of it's attributes is an object called Database (which extends MySQLi). On a child class of System (called Page), I want to use this Database object. But I keep getting a fatal error.
So here's some example code.
Any ideas on why this is happening? Thanks for any attempts. 
Could someone confirm if the problem is with my logic or not.
I have a class called System. One of it's attributes is an object called Database (which extends MySQLi). On a child class of System (called Page), I want to use this Database object. But I keep getting a fatal error.
Code: Select all
Fatal error: Call to a member function real_escape_string() on a non-objectCode: Select all
class System
{
protected $database;
public function __construct()
{
// ... Variables are included here
$this->database = new Database(DB_HOST,DB_USER,DB_PASS,DB_NAME);
}
}
class Database extends MySQLi
{
// yada yada
}
class Page extends System
{
private function get_page($title)
{
$this->database->real_escape_string($title); // [color=#FF0000]This line causes the error[/color]
}
}