Alan Knowles has an interesting post on PDO.
I really don’t know much about PDO, i haven’t used it yet. Most of what I know comes from:
Wez Furlong’s first steps with PDO examples
Wez’s Oracle PDO Article
John Lim’s discussion of adodb and PDO
A sitepoint thread on PDO
I haven’t seen any API type docs yet. I did download an older version of the PECL code and skim through it.
Alan has some interesting things to say. I have to agree with him on using libgda as a back end. Using a more mature, existing, debugged code base seems very reasonable to me. Could libgda be used as the PDO back end while retaining the PDO front end API?
When I first looked at PDO, the parameter binding is one of the things that really jumped out at me. It reminded me of register globals, a technique that didn’t necessarily turn out well and was painful to back out of. Now that Alan says it, this technique is a bit more reminiscent of C than PHP. As i understand its an optional way to use PDO. A way that I would not use.
- copying C: I agree that bound parameters can lead to magic code. There are two things to keep in mind: a good coding style (with comments) is the best remedy for code that might be considered magic.
I have to strongly disagree on the coding style point. Salting magic code with comments does not make it palatable. The solution is to remove the magic.
I am not familiar enough with PDO to understand the iterator argument. None of the examples I have seen actually use iterators.
What I would like to see out of a basic OO DB API in PHP is better support for translating the database record into an object. For example, the fetch(PDO_FETCH_OBJ) method returns an anonymous object. I would like a way for this method to construct an object of a particular class along with an initialization protocol such as unserialize has with objects.
I do think that PDO should be a part of core PHP, but perhaps one with a more mature libgda backend and a more evolved PHP front end API, influenced by Alan’s feedback and DBDO efforts.
I have noticed that sometimes the API design in PHP tends to simply wrap underlying 3rd party C libraries, even when that design doesn’t make the most sense in PHP. (for example the PHP wrapping of expat) PDO is a more of an attempt to design a PHP oriented API and then work the 3rd party libraries into the common design. To me, this is a step forward. However, the PDO API probably needs to go through a few iterations as Alan suggests before being frozen into core PHP.