Home arrow PHP arrow Completing a CodeIgniter Library with Method Chaining

Completing a CodeIgniter Library with Method Chaining

In this eleventh part of a 12-part series on method chaining, I will finish building the custom CodeIgniter library we've been working on by adding to it some very useful features. When we're done, the library will be able to autoload a specified model and validate input data.

TABLE OF CONTENTS:
  1. Completing a CodeIgniter Library with Method Chaining
  2. Adding more chainable methods to the abstract model class
  3. Autoloading models and validating incoming data
  4. The final version of the abstract model class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
December 02, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

True to form, method chaining is a powerful approach that lets programmers build compact and highly modular class interfaces. Of course, this methodology isn’t a proprietary feature of a particular language, which means that it can be applied quite easily in PHP 5.

Thus, if you’re a PHP developer who wishes to expand your existing skills and learn how to create and implement chainable methods when using the object-oriented paradigm, then this series of articles might be the material that you’re looking for.

Naturally, if you already had the chance to read all of the articles that precede this one, then you now have a solid background in how to create chainable interfaces in PHP 5, and how to use them for building a custom model for the CodeIgniter framework.

Speaking more specifically, in the previous article I demonstrated how to expand the functionality of this model by coding a set of chainable methods. These were tasked with building several WHERE modifiers  for appending to a given query.

As you’ll surely recall, the implementation of these methods was  a straightforward process, so it’s time to mention the topics that will be covered in this penultimate chapter of the series. Thus, as the above title suggests, in the next few lines I’m going to finish developing this custom model for CodeIgniter by adding to it some methods that will perform crucial tasks, such as automatically loading classes required by the model and validating the data required for inserting and updating database records, and building error strings and creating other common query modifiers dynamically as well.

Now, it’s the time to complete this abstract model. Let’s get going!



 
 
>>> 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 2 - Follow our Sitemap

Dev Shed Tutorial Topics: