Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Class 'Model' not found in CodeIgniter

My CI version is CI2.3. I'm running this php code in my local host. I followed all the steps given there but I'm getting this error don't know why? and I changed Controller to CI_Controller. Hello world Program worked finely. This link code is not working. please need help!

like image 229
Suheal Pasha Avatar asked Jul 03 '13 04:07

Suheal Pasha


2 Answers

you should extend model like this in codeIgniter

class Modelname extends CI_Model
  {
   function __construct()
    {
          parent::__construct();
    }
  }
like image 105
Rajeev Ranjan Avatar answered Oct 04 '22 10:10

Rajeev Ranjan


Well actually the study guide is of old version of CI, where you used to extend your models from Model class as show in the guide. But now it has been changed. Now you have to extend it from CI_Model, same goes 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();
  }
}
like image 25
Mohammad Ismail Khan Avatar answered Oct 04 '22 12:10

Mohammad Ismail Khan