HomePHP Paginating Database Records with the Code Igniter PHP Framework
Paginating Database Records with the Code Igniter PHP Framework
In the previous tutorials in this nine-part series, we built a simple application with the Code Igniter PHP framework. In this article, the third part of the series, we're going to add some important functionality to this application by using the pager class included with Code Igniter.
Building PHP applications using a third-party framework can be a time-consuming process, particularly in those cases where the software chosen requires installing and configuring a large number of source files, as well as dealing with a long and difficult learning curve.
Luckily, not all PHP frameworks are created in the same painful way. A good example of this is Code Igniter, a solid piece of software written in PHP 4 that allows you to develop full-featured web applications by means of a friendly API, and by taking advantage of the functionality provided by the Model-View-Controller pattern.
Therefore, if you’re interested in learning how to use the powerful tools that come packaged with Code Igniter and start creating full-blown database-driven applications in a very short time, then you should start reading this group of articles now!
And speaking of articles, you’ll surely recall that in the previous one, I explained how to develop a simple MySQL-based web application, which was capable of fetching a few rows straight from a database table and displaying their contents on the browser.
However, even though the functionality of this introductory application was fairly limited, it’s worth mentioning that this example was built by utilizing the MVC pattern. This means that it was comprised of three modules, that is a model class, then the corresponding controller and finally a simple view for embedding these database rows into a basic HTML page.
As you may guess, however, Code Igniter comes bundled with a robust set of core classes, which can be used to perform all sorts of clever tasks, such as working with databases, performing file uploads, validating user-supplied data, and so forth.
So, in this third chapter of this series, I’m going to show you how to improve the MySQL-driven application developed in the preceding tutorial, since it’ll be provided with the capacity for paging database records, via the pager class included with Code Igniter.
Now, it’s time to get rid of the boring theory and see how easy is to build a pagination system with Code Igniter. Let’s jump in!