Tag Archives: Codeigniter autoload models not working

Codeigniter Autoload Models


Codeigniter autoload models: You can auto-load models instead of loading it again and again.


Syntax : Codeigniter autoload models

1. Go to application/config/autoload.php
2. Go to the below lines

$autoload['model'] = array();

3. Now Add your model you want to auto-load.

$autoload['model'] = array('yourmodel_name');

For Multiple Models :

$autoload['model'] = array('yourmodel_name1','yourmodel_name2','yourmodel_name3');

Example : Codeigniter autoload models

$autoload['model'] = array('My_first_model');

Now you can access this model without loading it again in controller.

Example

My_first_model->getData();
     $this->load->view('MyUsers_view', $data);

  }

}
?>