Create CodeIgniter Model

The Model represents your data structures. Usually your model classes will contain functions like retrieve, insert, and update information in your database. It is stored in application/models.

<?php
class Model_name extends CI_Model{

    public function __construct() {
        parent::__construct();
    }

    public function save()
    {
        // Query Statement
    } 
?>

CodeIgniter class name and file name same above your Model_name is your class then your file name will be Model_name.php

Model classes are stored in your application/models/ directory. They can be nested within sub folders if you want this type of organization.

The basic formate for a model class is this:

class Model_name extends CI_Model {

}
        

Where Model_name is the name of your class. CodeIgniter Class name must be the first letter is capital with the rest of the name lowercase. Make sure your class extends the CodeIgniter base Model class.

Loading Model :

Models are loaded in the conntroller's file with the following code line:

$this->load->model("Model_name");