All,
I'm a fairly new and I mostly studied OOP with Java.
With this said, here is the relevant code:
Model.php
class Model{ // Object that represents a connection to the relevant db table
private $db; //contains the identifiers of the db
private $dao;
function createRecord1(){
return $this->dao->createRecord();
}
}
User_Model.php
class Model_user extends Model {
function __construct($db){
$this->db=$db;
$dao=DAO_DBrecord::createUserDAO($this->db);// This is a static function that calls the DAO constructor with a 'user' table name parameter
$this->dao=$dao;
}
}
Then in Controller_Register.php, I have this code:
//Some other code
$db=DB::createDB();
$userModel=new Model_User($db);
$userID=$userModel->createRecord1();
//Some more code
This yields the error message I have in the title. The line return $this->dao->createRecord();
inside Model.php
causes the error.
There is no error if the function createRecord1()
is placed in Model_User
instead of in the parent class - but then of course I would have to duplicate it in other children.
What am I doing wrong?