menu

Codeigniter Load Model


Codeigniter load model : $this->load->model(‘Your_model_name’); is used to load models in Codeigniter.


Codeigniter Load Model Syntax

Note if you are using subfolders in models. Example your model file is within the “application/models/users”
folder then in this case you need to load the models in this way :

For Example : load model users_model which is inside the users folder.

Codeigniter Load Model Example

Codeigniter Load Model Example

If you want to load model in library Read – http://tutorialsplane.com/codeigniter-load-model-in-library/

Codeigniter Load Model Example

1. Create Model :
place it in application/models folder

2. Create Controller :
place it in application/controllers folder

Now Load model from and get data from users table.

3. Create view :
place it in application/views folder

Now We are going to print user data from users table.

Now Access the url “http://localhost/MyUsers/users”

Demo┬╗

Advertisements