Models
What is a Model
In any application you have to call a capacity to recover some data from the database. Models obligation is to deal with all information rationale and portrayal and burden information in the perspectives. It is put away in application/models.
Take a gander at the above depiction, this is the essential struacture of a model record.
Here, ModelName is the name of your model record. Keep in mind, class first letter must be in capitalized letter followed by other lowercase letters and it ought to be same as your document name. It broadens the base CodeIgniter Model so all the implicit techniques for parent Model document gets acquired to the recently made record.
Model document name will be spared with a capitalized letter in the organizer application/models. For instance, on the off chance that the above Modelname is your class, at that point your document name will be ModelName.php
Loading a Model
Models are stacked in the conntroller's document with the accompanying code,
$this->load->model('ModelName');
In the event that in the event that your model record is situated in sub-catalog of model envelope, at that point you need to specify the full way. For instance, if your document area is application/controller/models/venture/ModelName. At that point, your document will be stacked as demonstrated as follows,
$this->load->model('project/ModelName');
Connecting Models to Database
Stacking a model doesn't mean it will naturally interface with your database. There are various strategies to associate a database.
.Auto-associate component will consequently stack your database with each page load. To empower it, include word 'database' in the exhibit library in autoload.php record.
Physically associate database by including this code in the page where required.
$this->load->database();