Home arrow PHP arrow Completing the MySQL Class with Method Chaining

Completing the MySQL Class with Method Chaining

Among the numerous features provided by PHP 5, thereís one that many developers find appealing. It permits the building of compact and modular programming interfaces. Yes, as you may have guessed, in this specific case Iím talking about method chaining, a programming approach can be easily mastered by those with an average background in the object-oriented paradigm. This is the sixth part of a 12-part series on method chaining.

  1. Completing the MySQL Class with Method Chaining
  2. Review: creating ORDER BY SQL clauses with chainable methods
  3. Dynamically creating the LIKE part of a query
  4. Adding a chainable factory method to the MySQL class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
November 09, 2009

print this article



Indeed, learning how to create chainable methods in PHP 5 class is a pretty straightforward process that will make your own classes more compact and modular as well. Therefore, I suggest you read this series of articles; in it, you'll find an approachable guide that will show you the basics of using method chaining and how to implement this approach for developing real-world programs.

And now that you're aware of the main goal of this series, it's time to review the topics that were discussed in the last article, as a quick reminder. In that installment I showed how to add a simple chainable method to the MySQL abstraction class previously developed. It was used for creating the "ORDER BY" part of a SELECT statement.

Defining a method like this allowed us to retrieve database records by using only a few lines of compact code. Now I'd like to finish building this sample MySQL abstraction class by adding to it two final chainable methods. The first one will be charged with building the "LIKE" clause of SELECT queries, while the second method will be a factory responsible for returning to client code only singletons of this class.

Want to see how these two useful methods will be defined? Then click on the link that appears below and keep reading.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates


Dev Shed Tutorial Topics: