Home arrow PHP arrow 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.

TABLE OF CONTENTS:
  1. Adding Ordering and Grouping Clauses to the CodeIgniter Library with Method Chaining
  2. Creating the JOIN, ORDER BY and GROUP parts of a query
  3. Conditional queries: adding WHERE modifiers to a SELECt statement
  4. The custom model class's full source code
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
November 25, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap

Dev Shed Tutorial Topics: