HomePHP Running Conditional Select Statements with the Active Record Pattern
Running Conditional Select Statements with the Active Record Pattern
If youíre a PHP programmer who wants to learn how to implement the active record pattern within a MySQL abstraction class to make your database-driven applications more robust and maintainable, then look no further. Welcome to the third part of a series focusing on the active record pattern. Made up of seven articles, this series explains how to take advantage of the functionality provided by this popular design pattern to build an extensible MySQL-accessing class. This class will allow you to perform several queries without explicitly writing any SQL statements.
Now that youíre aware of the main goal of this group of tutorials, itís time to review the topics we covered in the last article. In that part, I walked you through the development of a basic MySQL abstraction class, which was capable of fetching, inserting, updating and deleting database records (also known as CRUD operations) by means of the active record approach.
Basically, this implied that the MySQL-accessing class was provided with the capability for running all of these queries without the need to manually code the corresponding SQL clauses, a feature that helped to abstract SQL code.
However, as you may have guessed, thereís plenty of room for enhancing the functionality of this simple class. With that idea in mind, in this third chapter of the series Iím going to show you how to add a new method to the class. It will be charged with executing conditional SELECT statements via a modified version of the active record pattern.
Now, with the preliminaries out of our way, itís time to dig deeper into this interesting topic. Letís get going!