HomePHP Expanding a Custom CodeIgniter Library with Method Chaining
Expanding a Custom CodeIgniter Library with Method Chaining
Welcome to the eighth installment of a series on method chaining in PHP 5. With numerous code samples, this series shows you how to define chainable methods within your own PHP classes. Best of all, it teaches you how to implement this powerful programming method in a real-world case: developing an abstract model for the CodeIgniter framework.
Naturally, if you already read the preceding article of the series, at this point you have a clearer idea of how to apply the method chaining approach to building a customized model class for CodeIgniter. In that tutorial I started to create such a class. It had the ability to fetch and insert/update the records of an associated database table through a few methods, some of which were chainable.
However, as you might have guessed, this CodeIgniter class has a rather limited functionality in its current state. Therefore, in this tutorial of the series I’m going to add more methods to it, which will permit it to delete database rows, as well as build different portions of SELECT statements. And guess what? These last methods will be chainable too!
Now, it’s time to begin coding the methods for this custom CodeIgniter library. Let’s jump in!