Open In App

Explain basic structure of a MVC model

Models, Views, and Controllers (MVC) patterns are used by CodeIgniter to organized the files. This helps us to maintain the data, the presentation, and flow through the application. To make things more clear we can understand with their basic definition:

In the most basic way of understanding, controllers and models are simply classes that have a specific job. They are not the only class types that you can use they also make up the core of how this framework is designed to be used. They even have designated directories in the /app directory for their storage of files like controllers, models, views, helpers, config, and many more, though you’re free to store them wherever you desire, as long as they are properly named.



Introduction To Models:

  1. Enforce business rules on the data as it is pulled from, or put into, the database.
  2. Handle the actual saving and retrieval of the data from the database.

For many developers, the confusion comes in determining what business rules are enforced. It simply means that any restrictions or requirements on the data are handled by the model. This might include normalizing raw data before it’s saved to meet standards and requirements, or formatting a row/column in a certain way before handing it to the controller. By keeping these business requirements in check to the model, you won’t repeat code throughout several controllers or accidentally miss updating an area. Models have typically stored in the “/app/Models” location in their file structure.



Directory of Models in “/app” folder.

Article Tags :