Introduction to PHP 5 PDO

Share this article

Hi! I’m David Mytton the new SitePoint PHP Blogger and I am going to be writing for this blog for at least the next 3 months. I am going to try and focus on technical posts to provide some useful code and information about new (and old) features in PHP, so hopefully it will be a good learning experience for myself and readers.

A little bit about me:

I have written several articles for SP in the past, mostly reviews or interviews and I have also had a few articles published in International PHP Magazine. I am also the author of Invision Power Board 2: User Guide, a new book for IPB due out very shortly. In addition to writing for print, I also write commercial and open source PHP software through my limited company, Olate, in the UK.

Aside from computing, I do scuba diving and fencing (yes, with swords!).

If you have any ideas for posts for the blog, please get in touch. There is a box on the bottom left of this post “Suggest a Post” which allows you to do this.

Anyway, onto the main post…

[u]Introduction to PHP 5 PDO[/u]

The new PHP Data Objects (PDO) have been covered in a past blog post but I thought that I’d cover it in a little more detail.

After reading the blog post and also Wez Furlong’s blog I had a play around with some PDO code. Although there are already some PHP database abstraction classes available, the advantage of PDO is that it will be available in any PHP installation (so long as it is enabled) at runtime, without any need for recompiling. In addition, since it has been written from scratch specifically for PHP 5, it has a high level of performance. And if you are like me and often only want the key features, then PDO provides all the essential functions you need to connect to different databases. If you need the “full works”, then the PEAR MDB2 package can handle that.

[u]Note:[/u] PHP 5.1 Beta 3 was released on 14th July and included a number of updates to PDO. You can find out about these changes at

Before we go on, here is an important note from Wez Furlong (the developer of PDO):

Please note that PDO and its drivers are currently in an “alpha” state; this means that we are reasonably sure that there are no major bugs, but that the package is not feature complete

David MyttonDavid Mytton
View Author
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week