1.

Explain Model in codeIgnitor and how to load them.

Answer»

 In any dynamic application we need to call some function to get data from the database.  MODEL handles all data logic and representation and loads the data to view. 

<?php Class FirstModel extends CI_Model { function __Construct() { parent::_construct(); } }

FirstModel is the model NAME and same should be your file name. It extends the core codeIgnitor model which provides all the built-in functionality. 

To load a model use : $this->load->model('ModelName');

Manually connect database by adding $this->load->database();  in the page whereever required. 

Connect model to database : 

.Auto-connect feature helps to load database with every page load. To enable it add ‘database’ to array library autoload .php 

It will be LIKE : $autoload[‘LIBRARIES’] = array(‘database’);



Discussion

No Comment Found