Database Articles

  Home arrow Database Articles arrow Introducing PDO
DATABASE ARTICLES

Introducing PDO
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2010-08-25

    Table of Contents:
  • Introducing PDO
  • Another Database Abstraction Layer?

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Introducing PDO


    (Page 1 of 2 )

    In this first article of a five-part series, you'll learn about database abstraction layers: why they exist and what they're used for. You'll also be introduced to the PHP Data Objects (PDO) abstraction layer. This article is excerpted from chapter 23 of the book Beginning PHP and Oracle: From Novice to Professional, written by W. Jason Gilmore and Bob Bryla (Apress; ISBN: 1590597702).

    While all mainstream databases adhere to the SQL standard, albeit to varying degrees, the interfaces that programmers depend upon to interact with the database can vary greatly (even if the queries are largely the same). Therefore, applications are almost invariably bound to a particular database, forcing users to also install and maintain the required database if they don’t already own it or, alternatively, to choose another possibly less capable solution that is compatible with their present environment. For instance, suppose your organization requires an application that runs exclusively on PostgreSQL, but your organization is standardized on Oracle. Are you prepared to invest the considerable resources required to obtain the necessary level of PostgreSQL knowledge required to run in a mission-critical environment and then deploy and maintain that database throughout the application’s lifetime?

    To resolve such dilemmas, enterprising programmers began developing database abstraction layers, which serve to decouple the application logic from that used to communicate with the database. By passing all database-related commands through this generalized interface, it became possible for an application to use one of several database solutions, provided the database supported the features required by the application and the abstraction layer offered a driver compatible with that database. A graphical depiction of this process is found in Figure 23-1.


    Figure 23-1.  Using a database abstraction layer to decouple the application and data layers

    It’s likely you’ve heard of some of the more widespread implementations, a few of which are listed here:

    MDB2: MDB2 is a database abstraction layer written in PHP and available as a PEAR package. (See Chapter 11 for more information about PEAR.) It presently supports FrontBase, InterBase/Firebird, MySQL, Oracle, PostgreSQL, and SQLite. If you require support for Informix, Mini SQL, ODBC, or Sybase, see the PEAR DB package, which was MDB2’s precursor.

    JDBC: As its name implies, the Java Database Connectivity (JDBC) standard allows Java programs to interact with any database for which a JDBC driver is available. Drivers are available for MSSQL, MySQL, Oracle, and PostgreSQL, among others.

    ODBC: The Open Database Connectivity (ODBC) interface is one of the most widespread abstraction implementations in use today, supported by a wide range of applications and languages, PHP included. ODBC drivers are offered by all mainstream databases, including those referenced in the previous JDBC introduction.

    Perl DBI: The Perl Database Interface (DBI) module is Perl’s standardized means for communicating with a database and was the inspiration behind PHP’s DB package.

    As you can see, PHP offers DB and supports ODBC; therefore, it seems that your database abstraction needs are resolved when developing PHP-driven applications, right? While these (and many other) solutions are readily available, an even better solution has been in development for some time and has been officially released with PHP 5.1. This solution is known as the PHP Data Objects (PDO) abstraction layer.

    More Database Articles Articles
    More By Apress Publishing

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap