HomePHP 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.
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!