PDO offers a nice interface, but greater versatility also means more problems to solve the subtle features of each backend. If you look at bugtracker , it has a number of open problems, and some of them are serious.
Here's anecdotal evidence with postgresql: the PDO parser has problems setting standard_conforming_strings to ON (which is now the default, as with PG-9.1). Test case with php-5.3.9:
$dbh->exec("SET standard_conforming_strings=on"); $p=$dbh->prepare("SELECT 1 WHERE 'ab\' = :foo AND 'cd' = :bar"); $p->execute(array(":foo" => "ab", ":bar" => "cd"));
The execute () function unexpectedly crashes at the PDO level with Database error: SQLSTATE[HY093]: Invalid parameter number: :foo . It seems that it cannot determine: foo as a parameter.
If the request stops after 'ab\'=:foo , without another condition, it works fine. Or, if the other condition does not contain a string, it works fine.
The problem is similar to question No. 55335 , which was rejected as not a mistake, completely wrong, in my opinion. [In fact, I even hacked the PDO myself to fix it, but in a way that is incompatible with other backends, so no patch. I was confused by the fact that the lexical query analyzer was so general.]
On the other hand, pg_ * is closer to libpq, such a problem is likely to happen in the first place, and it is easier to solve if this happens.
So, I would say that not everything is good with PDO. Internally, this is of course more complex than pg_ *, and more complexity means more errors. Are these errors considered? Based on some error records, optional.
Daniel Vérité
source share