I have a CodeIgniter php setup and enhanced it with RESTful capabilities.
I have the following structure
base.php (this is the base controller class
class Base {
private $model
public function __construct($model = false) {
$this->model = $model . '_model';
$this->load->model($this->model);
...
}
And then a controller which specifies a model
class Products extends Base {
public function __construct() {
parent::__construct('product');
}
}
The problem is as follows: in base.php I have functions for HTTP methods (get, post, put, delete), but I am not able to call a static method from the model like so:
public function get() {
return $this->model::loadData();
}
If I assign $this->model
to a local variable in get()
it works, but it looks ugly to me.
So my question is: how can I call a static method of a class A given the class name in a member of class B without assigning it to a new local variable in methods of class B?
P.S.: I know CodeIgniter does not look like this, but the structure of it is irrelevant to my problem.