EDIT: SOLVED!
I have been working on my own framework lately. I have a controller class like this:
class Controller {
private $model;
public function __construct() {
global $bean_db, $mv_name;
if (file_exists(APP_PATH . 'models/' . $mv_name . '.php')) {
require APP_PATH . 'models/' . $mv_name . '.php';
$model_name = $mv_name . '_Model';
$model = new $model_name;
$this->model = $model;
}
}
}
Now, in a specific controller file, I have code like this:
class Start_Controller extends Controller {
function execute() {
$this->model->exec("SET NAMES 'utf8'");
}
}
As you may or may not expect, that did not work. I get an error message that the property named “model” does not exist. Can anyone help me solve this?
Because a
privatevariable is limited to this class only and not to any children.You need
protectedfor this case