Home arrow PHP arrow Using PDO Objects in PHP 5

Using PDO Objects in PHP 5

The PDO library is a powerful addition to PHP. It shines when you need to build applications capable of talking to different database systems. It also has other very useful capabilities. This article, the first in a three-part series, will introduce you to this versatile library.

TABLE OF CONTENTS:
  1. Using PDO Objects in PHP 5
  2. Using the PDO extension
  3. Running queries against a specific database
  4. Finding insertion IDs for database rows
By: Alejandro Gervasio
Rating: starstarstarstarstar / 32
May 29, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

PHP developers who used to work with different relational database systems have had two choices when it came to building their web applications. They either had to include a third-party library that allowed transparent handling of the interaction with RDBMSes, or, in the worse case, they had to create their own database abstraction layers, which was a time-consuming process.

In the first case, picking up a pre-built package that provided PHP programmers with a decent level of abstraction for using diverse database servers was reduced to choosing between a certain number of well-trusted libraries. These include the robust PEAR::DB, or the excellent ADODb database abstraction software, to name the most popular libraries.

However, in many cases PHP applications are conceived from the very beginning to interact only with MySQL, which facilitates their development enormously. In this situation the application does not need to work with multiple database systems. Consequently, in this case using a simple MySQL-related package can satisfy quickly all the eventual database requirements.

Nonetheless, there are times when a certain web application needs to interact with more than one database server. This implies having to build more complex classes (if you're using an object-oriented approach) or picking up a third-party library that may be capable of suiting these specific database requirements.

As you may have heard, for those PHP developers that frequently need to work with different database systems, I must say that good news are just around the corner. With the release of PHP 5.1 (and subsequent versions of the language, by the way), a brand new database abstraction layer has been included.

Yes, you guessed right! In this case I'm talking about the powerful PDO library. PDO is short for PHP Data Objects. The library consists of a versatile package that makes it easy to talk to popular database systems, such as MySQL, Oracle, MS SQL, and so on using a fully oriented object-based notation. Of course, the benefits of using this library don't end here; it also offers the possibility of processing result sets in all sorts of clever ways, handling stored procedures, performing transactions, using markers in queries, and so forth.

As you may have seen at first glance, the PDO extension looks really useful in certain situations. In this three-part series, I'm going to introduce its most important features, by accompanying the corresponding theoretical concepts with numerous hands-on examples, in this way facilitating the respective learning curve.

Now, are you ready to dive deeper into the powerful PDO library? Okay, let's begin now!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: