Organizing the logic of our site

This is possible, thanks to the structure of CI, as for this to be possible we need to separate our code in more than one file. CI follows the MVC design pattern, which means that we have our code divided into:

  • A controller—as a central point of our code, where data manipulation and other data operations are carried
  • A model—to retrieve data from a database or databases
  • A view—or more if necessary, to present the code to our visitors

Again, at first this may seem tight to work with. But it is very convenient and will make our code more maintainable. For example, if we want to read the records from our users2 table, we will need three files, one for each—controller, model, view.

A model

To retrieve the data we will create ...

Get CodeIgniter 1.7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.