Codeigniter Models - phptpoint

Codeigniter Models

PHP 6 Months 100% Job Assistance Program. for more info... call on 8588829328

Models

Models are the classes designed to work with information in the database. For example, if we are using CodeIgniter to manage users in our application then we must have model class, which contains functions to insert,update,display and delete data.

Creating Model Class

Syntax

Note : Model Classes always stored inside Applicaion/models directory.
Model Class name must be started with Capital Letters(or use camel case). Class name and Page name must be similar.
Each Model class inherit Codeigniter’s CI_Model Class .

Create a user’s Model Class

Here we have created a model class UserModel. UserModel Class must be saved inside Application/modesl/UserModel.php

Loading Model

Every Model class called/used inside a Controller. To call a model class inside controller following code can be used

After loading model class inside Controller we can use other methods of Model Class
Syntax

Latest Trending Technologies