HomePHP Using Visitor Objects with MySQL Data Sets in PHP 5
Using Visitor Objects with MySQL Data Sets in PHP 5
If you’re looking for brand new material to help you expand your background in using design patterns with PHP 5, then hopefully this article will suit your needs. Welcome to the final installment of the series “Introducing Visitor Objects in PHP 5.” Composed of three chapters, this series walks you through the key points of creating and using visitor objects with PHP 5, and teaches you how to use them in the context of real-world applications.
As you hopefully learned over the course of the two previous articles, building visitor classes is not only a fairly comprehensive process that can be done without much trouble, but it's also an exciting experience, which indeed deserves an in-depth look. That's why in the first article, aside from introducing the fundamentals of visitor objects, I showed you an introductory example, which demonstrated how a specific object, in this case called "the visited one" can accept another (the visitor) to allow the inspection of its properties.
In addition to the introductory example that I mentioned before, in the second tutorial I went through the development of a slightly more complex example. It illustrated how a highly generic "User" class could be inspected by its corresponding visitor, which resulted in the ability to access of all its visible properties without having to specifically use its own methods.
So far, implementing visitor objects with PHP is indeed a educational process, which helps to extend even more the boundaries of the vast arena of pattern-based programming. Based on this premise, in the course of this last article, I'll expand the application of the visitor pattern by developing a slightly more realistic example. It will show you how to use visitors objects to establish a direct relationship between a MySQL processing class and a pagination mechanism.
In return for all the code samples that you'll learn in this tutorial, you'll be equipped with a better grounding, not only with reference to this pattern in particular, but also regarding the main pillars of pattern-based web development. Thus, I think it's time to get rid of the preliminaries, and continue learning more about using visitor objects with PHP 5. Let's move on!