HomePHP Adding Ordering and Grouping Clauses to the CodeIgniter Library with Method Chaining
Adding Ordering and Grouping Clauses to the CodeIgniter Library with Method Chaining
Welcome to the tenth installment of a series on method chaining in PHP 5. Comprised of twelve tutorials, this series teaches you the key concepts that surround the implementation of chainable methods within PHP classes, and shows how to put them to work to create a custom library for the popular CodeIgniter framework.
And now that you know what to expect from this series of articles, itís time to refresh the topics that were discussed in the last one. In that part of the series I explained how to add some chainable methods to the already familiar ďAbstractModelĒ class, which was a pretty useful add-on for CodeIgniter.
Expressed in simple terms, the methods that I implemented within the class were responsible for creating the SELECT MIN, SELECT SUM and SELECT AVG parts of a SELECT SQL statement respectively. However, by sticking to the method chaining approach, itís also feasible to create methods that build other portions of a query, such as the JOIN, ORDER BY, GROUP BY, LIKE and NOT LIKE modifiers, and a few others as well.
So, with that premise in mind, in this tenth chapter of the series, Iím going to code a few more methods, (also chainable, of course) that will be charged with performing the aforementioned tasks in a simple manner.
Now, letís leave the preliminaries behind and continue expanding the functionality of the CodeIgniter custom library by means of the method chaining approach. Letís go!