Hi guys,
Im trying to make my own (very simple) MVC framework,
Atm i have a problem with loading classes,
i have a main controller class , in which i made a loadModel function like this :
Quote
public function loadModel ( $model ){
if (!file_exists(ROOT . '/models/' . $model . '.php'))
{
throw new Exception('Cannot load model : '.$model.'');
}
else {
include (ROOT . '/models/' . $model . '.php');
$model = new $model;
}
In my controller for the homepage (extends the main controller) i use the function like this : $this->loadModel('queries') .
When i use a var_dump in the loadmodel function like this : var_dump($model) it says an object has been created, however i cannot use this object in my homepage controller, it simply does not exist there somehow
Any1 knows how to fix this? I could just use include and make an object of it, but i want it do be done automaticly, so i can save time with this later
thanks!