Header Ads

Seo Services



PDO is an acronym for PHP Data Objects. PDO is a lean, consistent way to access databases. This means developers can write portable code much easier. 

According to php.net, It is an extension that defines a lightweight, consistent interface for accessing databases in PHP.

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data.

PDO ships with PHP 5.1, and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the core of PHP 5, and so will not run with earlier versions of PHP.

With the technical definition out of the way, we can now do some coding... i advice you do more reading on the official php website.

Before you can use PDO, as stated above you must use the right version of PHP. To check your version of PHP, copy the code below:


Run it, you should see your version boldly written at the top. Mine is 5.5.12

After making sure you have the right version, you need to ensure your server can use the PDO extension, meaning you need to allow the extension... follow the steps below to do that:

1. Open php.ini file

 2. Press Ctrl + F to search for PDO

3. Locate {extension=php_pdo_mysql.dll} and remove the comment {;} if it is commented out. There are other PDO extensions but for the sake of this tutorial we will be working with MYSQL.

4. Save the php.ini file
5. Restart your server.

To test that you're ready, do the following:

This is to reconfirm that the PDO driver is now active, you should get:

In my next post we will do actual PDO MYSQL Connection.

Don't forget to share.

No comments