Fatal error: class 'CI_Model' not found in

My problem is to have a super model class with common functions for routines with models (findByPk, FindByAttributes, etc.).

For thjs, I decided to create a new library that extends the class CI_Modeland extends all models from the class MY_Model.

So, I added an array MY_Modelto $autoload['libraries'].

When adding modelto this array, I got an error:

Unable to load requested class: Model

But the main problem is that when I start the application, I get:

Fatal error: class 'CI_Model' not found

CI_ModelA class in the folder coreexists. So please tell me what could be the explanation of “why I cannot extend the CI_Model class in my library using MY_Model!”

+4
source share
2 answers

using

$autoload['models']

to load models automatically, instead of $ autoload ['libraries']

+10
source

Check


  • class CI_Model, which must be in ../system/core/Model.php. and extends the model name to the same as the class name.
  • create your model in application\models\your_model.php.
  • $autoload['model'] = array('your_model');
0
source

Source: https://habr.com/ru/post/1524336/


All Articles