PHP Data Objects (PDO) is a PHP extension that provides a consistent interface for database connectivity. This means that it allows your PHP code to talk to a number of different database formats without you having to modify your code for each particular case. This is no different (on the face of it) to other PHP data-access abstraction layer mechanisms such as Pear’s MDB2 package and Zend’s DB package.

Note: PDO usually comes pre-installed with PHP 5.x.x, with the necessary drivers for sqllite already there. You will most likely want the MySQL drivers too. These can be installed using pecl. See the PHP PDO documentation for further details.

//Open our connection
$dbhandler = new PDO('mysql:host=localhost;dbname=yourdb', $db_user, $db_pass);

/*
... queries etc here { examples to come soon }; ....
*/

//Now that we are done with our connection, let's dispose of it
$dbhandler = null;

Share
Share →

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>