backup_cdi - SPLessons

CodeIgniter Application Flow

Home > Lesson > Chapter 9
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

CodeIgniter Application Flow

CodeIgniter Predefined Libraries

If you are using first time MVC architecture you might get confuse with the flow of the MVC. As I mentioned earlier Controller is the key for the application where the application flow will be start. You can create as much as controllers that needed by your application. When you are navigating one controller to other, make sure with routing. Core PHP application has the functionality like fetching or updating the data from or to the database. The same functionality will continue here in CodeIgniter only the difference is here it is an architectural manner. [php] // Controller public function __construct(){ parent::__construct(); $this->load->model(My_Model ','',TRUE); $this->load->database(); } public function index() { $data['Validate']=$this->My_Model->Validate_User()->result(); if($data['Validate']!='1') $this->load->view(index); // on failure loading index file else $this->home(); // on success calling home method } public function home() { $this->load->view('templates/header'); $this->load->view('home'); $this->load->view('templates/footer'); } [/php] Add 'index' file and 'home' file in views. First we loading the model file and the database.