As I explained in the introduction, my intention here is to develop a simple abstraction layer by using only a bridge class and a couple of "bridged" objects. The purpose of doing this is basically to have access to the MySQL server by utilizing either the conventional "mysql" extension, or the highly-improved "mysqli" library that comes bundled with PHP 5. Having explained how I plan to use the bridge design pattern in this specific case, let me show you the first class involved in this example. It consists of a simple wrapper for MySQL, and logically uses the respective "mysql" extension as well. Here is the signature for this brand new class. Please have a look at it:
As you can see, there's nothing special with reference to the MySQL wrapping classes listed above. Similar to many abstraction classes that you have possibly used in many web applications, these allow you to perform some simple operations, such as connecting to the server, selecting a specific database, running queries, and processing result sets in a few useful ways. However, the pair of MySQL wrapping classes that you just saw definitely aren't the main topic of this article. I defined them here only with the purpose of creating another application that lets you access the MySQL server, either with the traditional "mysql" extension, or the improved "mysqli" library. In this case, the first requirement has been already satisfied, since the previous classes use the conventional extension. Therefore, it's time to move on and see how to develop a bridge class which will allow us to use MySQL by utilizing the two mentioned libraries. Things are getting really exciting now! Therefore, if you want to learn how this bridge class will be created, please keep reading.
blog comments powered by Disqus |