how you will load or add a model in CodeIgniter?
how you will load or add a model in CodeIgniter?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Aviance School is one of the largest web solutions platform in India for developers to learn and share their programming knowledge and build their careers.
What is a Model?
Models are PHP classes that are intended to work with data in your database. For instance, suppose you utilize CodeIgniter to deal with a blog. You may have a model class that contains capacities to embed, refresh, and recover your blog information. Here is a case of what such a model class may resemble:
Add Model
Create a Users_model.php file in application/models directory.
Inside the class create methods for data processing.
Create a
getUsers()
method to select all records from theuser_master
table and return an Array response.Loading a Model
Your models will typically be loaded and called from within your controller methods. To load a model you will use the following method:
$this->load->model('model_name');