Page 1 of 1

PDO to use or not to use?

Posted: Sun Feb 01, 2009 1:38 pm
by kaisellgren
Hello,

I've been trying to decide whether to use PDO or not. The only reason why I would use is simple: prepared statements. I could make my own system with those SQL commands, but like MySQL says:
There are three new SQL statements to support this: PREPARE, EXECUTE, and DEALLOCATE PREPARE. This doesn't take advantage of the new binary protocol, so it should only be used for testing or when a native API isn't available.
Do you think there's a big difference of using and not using that new binary protocol? Is it worth switching to PDO, because of it?

Re: PDO to use or not to use?

Posted: Sun Feb 01, 2009 3:09 pm
by Benjamin
Reading your post made me search google to see what others have to say about it... It seems that there are people who swear by it, people who hate it, and people who are confused about what it is.

1. From my research I discovered that the interface is a bit off and overly complex. I have my own database class which will escape queries for me and I don't need to bother setting the data type for every variable in every query. If I were to use PDO it would almost seem like I would need to have the manual open for it everytime I write a query.

2. Contrary to what others say, PDO is not database abstraction. You cannot switch between db vendors without modifying your queries. It does not emulate missing features for a particular db vendor.

3. A lot of programmers are attracted to PDO because of it's fully OOP interface, but to me it seems to be nothing more then a glorified database class. The main features & benefits aren't really relevant to any programmer who already follows best programming practices.

At the end of the day if I was going to spend the time to integrate something like this into my codebase, I would need it to handle Abstraction, be intuitive to use, have a high quality code base, be highly efficient and easy to implement.

Use PDO? I say No.

Pop Quiz: You just ran a SELECT query using PDO. What's the best way to get the number of matching rows?