Posts

Showing posts from 2014

PDO (PHP Data Objects)

What is PDO?  PDO, the PHP Data Objects extension, is a data-access abstraction layer. But what the heck is that? Basically, it’s a consistent interface for multiple databases. No longer will you have to use the mysql_* functions, the sqlite_* functions, or the pg_* functions, or write wrappers for them to work with your database.  Instead, you can simply use the PDO interface to work with all three functions using the same methods. And, if you change databases, you’ll only have to change the DSN (or Data Source Name) of the PDO to make your code work.  PDO uses specific database drivers to interact with various databases, so you can’t use PDO by itself. You’ll need to enable the drivers you’ll use with PDO, so be sure to research how to do it for your specific host operating system on the PDO manual page. PDO is shipped with PHP 5.1 and is available from PECL for PHP 5.0. Unfortunately, as PDO equires the new PHP 5 object oriented features, it’s not available for PHP. H