Model-View-Controller (MVC)
CodeIgniter framework is based on MVC pattern. MVC is a software that gives you a separate logical view from the presentation view. Due to this, a web page contains minimal scripting.
Model
Models are managed by the Controller. It represents your data structure. Model classes contain functions through which you can insert, retrieve or update information in your database.
Some points to be noted
By default, index method is always loaded if you have not written any second method in the URL. For example, if your method is
Then your URL will be like
OR
But if your method is
Then your URL will be like
View
View is the information that is presented in front of users. It can be a web page or parts of page like header and footer.
Controller
Controller is the intermediary between models and view to process HTTP request and generates a web page. All the requests received by the controller are passed on to models and view to process the information. It is the center of your every request on your web application.
Some points to be noted
- The Controller file must be named starting with the uppercase letter.
- Class name should also start with the uppercase letter and should be the same as your file name.
- The given calss extends to the CI_Controller so that it inherits all its methods.
If you think that Models are of no use to you or they are more complex then you can ignore them and build your project using Controllers and views.