Fatal error: Model class not found in CodeIgniter

My version of CI is CI2.3. I am running this php code on my localhost. I followed all the steps listed here, but I get this error, I don’t know why? and I changed the controller to CI_Controller. Hello world Program worked fine. This link code does not work. you need help!

+4
source share
4 answers

you must extend a model like this in CodeIgniter

 class Modelname extends CI_Model { function __construct() { parent::__construct(); } } 
+3
source

You must create model in the model folder, for example my_model.php

And create a class like

 class My_model extends CI_Model { function __construct() { parent::__construct(); } } 

Remember class and file must be the same .

Docs http://ellislab.com/codeigniter/user-guide/general/models.html

0
source

Use it as

 <?php class Employee_model extends CI_Model { //load the constructor function __construct() { //inherit the parent constructor parent::__construct(); } } 
0
source

In fact, the tutorial refers to the old version of CI, where you used to extend your models from the Model class, as shown in the manual. But now it has been changed. Now you need to extend it from CI_Model, the same for Controller.

For controllers

 class Employee_controller extends CI_Controller { //load the constructor function __construct() { //inherit the parent constructor parent::__construct(); } 

}

and for models

 class Employee_model extends CI_Model { //load the constructor function __construct() { //inherit the parent constructor parent::__construct(); } } 
0
source

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


All Articles