I made a small framework where I have a problem linking the model to the controller.
The error: Call to undefined function Milkey\Controllers\test()
This is my controller class:
<?php
namespace Milkey\Core;
class Controller {
public $language;
public $view;
public function __construct() {
$this->language = new Language();
$this->view = new View();
}
}
My model class:
<?php
namespace Milkey\Core;
class Model extends \Milkey\Core\Controller {
protected $_db;
public function __construct() {
parent::__construct();
$this->_db = new Database();
}
}
And my model that I want to use in my controller:
<?php
namespace Milkey\Models;
class Login extends \Milkey\Core\Model {
public function __construct() {
parent::__construct();
}
public function test() {
return 'yes';
}
}
So now, in my LoginController, where do I put this to use this model? $this->model->test(); does not work.
<?php
namespace Milkey\Controllers;
class LoginController extends \Milkey\Core\Controller {
public function __construct() {
parent::__construct();
$this->language->load('login');
}
}
Anybody who could explain me what I am doing wrong? Thank you.
Question
'Ricardo
I made a small framework where I have a problem linking the model to the controller.
The error: Call to undefined function Milkey\Controllers\test()
This is my controller class:
My model class:
And my model that I want to use in my controller:
So now, in my LoginController, where do I put this to use this model? $this->model->test(); does not work.
Anybody who could explain me what I am doing wrong? Thank you.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts