PHP
  Home arrow PHP arrow Abstracting Database Access Using Polymorphism with Objects in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Abstracting Database Access Using Polymorphism with Objects in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 11
    2007-03-21


    Table of Contents:
  • Abstracting Database Access Using Polymorphism with Objects in PHP 5
  • What shouldn't be done when accessing distinct database systems
  • Using Polymorphism to create a database abstraction layer
  • Demonstrating the functionality of Polymorphism

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Abstracting Database Access Using Polymorphism with Objects in PHP 5
    ( Page 1 of 4 )

    Polymorphism is an object-oriented programming concept that can be difficult to understand. This article, the first of a three-part series, walks you through the basics of Polymorphism so that you can make use of it in your own applications. The specific example in this article will show you how to use it with different database systems.

    Introduction

    Since the introduction of a highly improved object model in PHP 5, developing object-based applications with the latest version of this neat scripting language has been a greatly simplified process. This is naturally due to the implementation of diverse and powerful object-oriented features, such as visibility of class members, type hinting and exceptions, to name a few.

    However, while it should be admitted that the aforementioned improvements indeed facilitate working with classes and objects in a straightforward way, it's also true that building object-oriented applications can be a hard-to-master process. Most of the time this is because of inadequate knowledge of the main pillars of the object-oriented paradigm.

    In this case, you'll possibly know that I'm talking about Inheritance and Polymorphism. But what can be wrong with putting these theoretical concepts into practice, after all? Well, if you've been developing object-based programs for a while, then you've probably been consciously defining parent classes here and there. Logically you've also created numerous subclasses to perform concrete tasks.

    I have to admit that Inheritance is rather easy to grasp. It can be applied successfully with only a decent background in object-oriented programming. Nonetheless, there's a part of this schema that very often is completely omitted, or misused, in the best case. As you may have guessed, I'm speaking of Polymorphism, certainly a concept that presents some abstract aspects. Consequently, it's much harder to apply than Inheritance, at least in a real-world context.

    But take a deep breath and think twice. Actually, in the arena of object-based programming it isn't too difficult to understand how objects that belong to the same family can have different behaviors, even when they're using the same methods. And besides, there's an additional question that needs to be answered: how can this feature be used to create more efficient PHP applications?

    As you can see, questions come up very quickly when it comes to taking advantage of Polymorphism in PHP. This implies that the subject in question deserves a closer look. Therefore, keeping in mind the interest you might have in how to get the most out of polymorphic objects in PHP 5, in this three part series, I'm going to take a deeper look at some concrete situations where Polymorphism can assists in developing more robust and efficient object-based applications.

    More specifically speaking, in this first installment of the series, 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.

    So, having established the topics that I plan to treat in this group of articles, let's get started now!



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

       

    PHP ARTICLES

    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek