HomePHP Utilizing the LIMIT Clause with the Active Record Pattern
Utilizing the LIMIT Clause with the Active Record Pattern
Welcome to the fifth installment of a series focused on using the active record pattern with PHP. Made up of seven episodes, this series walks you through the progressive development of a MySQL abstraction class that utilizes the active record approach to perform CRUD (Create, Remove, Update, Delete) database operations and SELECT queries, without having to explicitly code any SQL statements.
Now that you've been introduced to the main subject of this group of articles, it's time to recall the topics that were covered in the last one. In that specific tutorial I explained how to build a basic MySQL abstraction class, which was capable of performing the CRUD tasks mentioned before, in addition to fetching database records using the LIKE clause.
Of course, the structure of this class is rather primitive and definitely wasn't suited for use in production environments. Despite this disadvantage, it came in useful for demonstrating how it can be utilized for accessing MySQL databases by means of the active record approach.
However, it's fair to mention that the functionality of the class can be enhanced. In its current version, it'll be able to accomplish only a few basic database operations tasks. Therefore, this fifth article of the series will be focused on enabling the class to fetch database rows by using the LIMIT clause.
By following the same approach demonstrated in preceding articles, this brand new capacity will be implemented through the active record pattern, in this manner extending its utilization within a MySQL abstraction class even more.
Now, it's time to get our hands dirty with a few functional PHP code samples. Let's jump in!