News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DevShed:
Abstracting Database Access Using Polymorphism with Objects in PHP 5
March 21, 2007 @ 15:21:00

In a new article from DevShed, they walk you through a method of using abstraction and objects along with polymorphism to work with databases.

I'll be explaining how to implement Polymorphism to achieve a high level of abstraction when accessing different database systems. Subsequent articles will cover the use of polymorphic objects to build dynamic web documents and validate user-supplied input.

They start out with a bad example of a database link in a PHP script, a database handler that, based on what type of database you tell it you're using, handles the requests appropriately. This is good, but poor design - their alternative is using objects (created from classes of one type for each kind of database). These are pulled together in a factory class and the correct one is built - out into a generic database object that's smart enough to know what it's supposed to do.

1 comment voice your opinion now!
tutorial polymorphism database access mysql sqlite abstraction layer tutorial polymorphism database access mysql sqlite abstraction layer


blog comments powered by Disqus

Similar Posts

Hakre's Blog: Iterating over Multiple Iterators at Once

Robert Basic: Unit testing Zend Framework 2 modules

WebSpeaks.in: Cross Domain Posting using PHP and JavaScript: ITS POSSIBLE!

ServerGrove Blog: Symfony2 components overview: Finder

Internet Super Hero Blog: Compiling mysqlnd with PHP 5.2/5.3/6.0


Community Events





Don't see your event here?
Let us know!


deployment framework symfony api conference laravel language code list community release series podcast introduction interview zendserver bugfix tips threedevsandamaybe voicesoftheelephpant

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework