Php Data Objects Tutorial

What is Php Data Objects (PDO) in php?


PDO is a consistent and light weighted interface used for accessing multiple databases in php.

PDO extension is introduced in the year of 2004 as the supporting feature of PHP 5.0 version.
Mysql_connection replaced with PDO
Most of the programmers use MySQL extensions to access the database but PDO is much powerful and portable. As PDO uses a unified API (Application Programming Interface), php programmers can easily write down the portable codes. So Mysql_connection was deprecated and replaced with the PDO extension recently.
Why PDO?
PDO has different drivers to access different SQL vendors. Whatever the database you work with, you can still use the same functions to fetch data as PDO offers uniform method to access multiple databases. You can also use the static method PDO::getAvailableDrivers() to check the available drivers.

foreach(PDO::getAvailableDrivers() as $driver)
echo $driver.'<br />';

PDO Supported Databases

  • FreeTDS / Microsoft SQL Server / Sybase - PDO_DBLIB

  • Firebird/Interbase 6 - PDO_FIREBIRD


  • IBM Informix Dynamic Server - PDO_INFORMIX

  • MySQL 3.x/4.x/5.x - PDO_MYSQL

  • Oracle Call Interface - PDO_OCI

  • ODBC v3 (IBM DB2, unixODBC and win32 ODBC) - PDO_ODBC

  • PostgreSQL - PDO_PGSQL

  • SQLite 3 and SQLite 2 - PDO_SQLITE

  • 4D - PDO_4D

PHP Topics

Ask Questions

Ask Question