Reputation: 231
My problem is to make super model class with common functions for routines with models(findByPk, FindByAttributes and so on).
For thjs I decided to make new library that extends CI_Model
class and to extend all models from MY_Model
class.
So I added MY_Model
to $autoload['libraries']
array.
When adding model
to this array I've got error:
Unable to load the requested class: Model
But main problem is that on application start I get:
Fatal error: Class 'CI_Model' not found
CI_Model
class in core
folder exist. So please say What maybe the explanation "why I cant extend CI_Model class in my library with MY_Model!"
Upvotes: 5
Views: 4490
Reputation: 65
Maybe it's late, but for future readers.
before loading your library in the constructor of the controller class, load any model of your creation then load the library that extends the CI_model. check the below:
public function __construct() {
parent::__construct();
$this->load->model('User_model');
$this->load->helper('url_helper');
$this->load->library('session');
$this->load->library('form_validation');
$this->load->library('admin_auth');
$this->load->helper(array('form', 'url'));
}
as you see, that I have loaded the User_model then the admin_auth. hope this helps
Upvotes: 0
Reputation: 2042
Check in
../system/core/Model.php
. and your extends model name same as class name.application\models\your_model.php
.$autoload['model'] = array('your_model');
Upvotes: 0
Reputation: 621
use
$autoload['models']
for loading models automatically, instead of $autoload['libraries']
Upvotes: 11