HomePHP Creating a MySQL Abstraction Layer with Bridge Classes in PHP 5
Creating a MySQL Abstraction Layer with Bridge Classes in PHP 5
If learning how to incorporate creational design patterns into your own PHP 5 applications is a high-priority topic for you, then this set of comprehensive articles might be what you’re looking for. Welcome to the concluding installment of the series “Using Bridge Classes with PHP 5.” These tutorials will teach you how to implement the bridge pattern in PHP by providing you with many hands-on examples that can be included in your existing and future web projects.
Before I move on and pay attention to the subject of this final article, first I'd like to refresh, at least quickly, some topics that were covered with detail in the preceding part of the series. As you'll certainly recall, in the previous tutorial I extended the implementation of the bridge pattern with PHP 5, by defining a bunch of straightforward classes, which when used in conjunction, followed the principles dictated by the mentioned pattern.
Speaking more specifically, I created a bridge class called "BridgeDataValidator" which defined the generic structure of a data validation object. This is handy for checking different types of user-provided input. However, the most relevant aspect of this schema rested on the capacity offered by the referenced class to create distinct data validator objects. These objects implemented concretely the required logic for checking numbers, alphabetic values, and email addresses.
Naturally, the data validation objects were conceived as independent structures, which resulted in the complete decoupling of the "BridgeDataValidator" class from its own implementation. Of course, if you're familiar with how the bridge pattern works, then you'll realize that all the classes that I developed in the previous tutorial precisely followed that model.
Now that I hopefully refreshed the topics that were treated in the preceding article of the series, it's time to focus your attention on the current one. The question that comes up now is the following: is there anything else that can be said about the bridge pattern? Of course there is! In this final tutorial I'm going to show you how to create a highly expandable abstraction layer that will allow you to work with MySQL using different libraries. This sounds interesting, right?
Having introduced the subject of this installment, let's leap forward and discover together how to build a MySQL abstraction layer, in this case using the bridge pattern. Let's get going!