General concepts | drupal.org:

The Drupal database layer is built atop PHP's PDO library. PDO provides a unified, object-oriented API for accessing different databases but it does not provide an abstraction for the different dialects of SQL used by different databases.


I believe the implication is that Drupal has those drivers to attach to multiple SQL rdbms.

Look, hiding the SQL is all well and good, but what you really end up with isn't a savings. It's platform lock-in. If I know Drupal's flavor of PDO, I can't do anything with an ANSI SQL compliant rdbms in Java. I can't do it with VB.NET/ADO.NET. I can't do it with RealBasic's crazy database features. I only know PDO.

If I already knew ANSI SQL, I have to learn a whole new language, not just a dialect. I've SQuirreL-SQL'd my way from MS SQL Server to Jet to Postgres to MySQL to Oracle to Sybase to Derby to... you get the point. There are minor flavor changes from one rdbms to another, but nothing, nothing as involved as learning this PDO crap.

There's really only one place an abstraction layer like this makes sense, and that's if you're looking to move to another rdbms. Perhaps many develop on AMP and move to MS SQL or Oracle, but I kind of doubt it. If you've normalized [your code] well, even that's not that big a task.

There are too many SQL abstraction layers out there when you really should just learn SQL. Instead of marrying yourself to a single MVC platform, you'll be ready to do your thing anywhere and in any language. This is why the guy who taught me to be a dba always said to stick as much logic as you can into the database where it belongs. I don't think we'll see many cursors or triggers or, most importantly, sprocs with either or both in PDO. Put your logic in the database system that's not going to change, and move from Drupal to Joolma to roll-your-own as quickly as possible. Save your data, not your interface.

(Now, I understand. They want you to use Drupal, not rdbms X. They want every Drupal module to work with every combo of available platforms. I get it. It's a mistake. ;^D)

You're always picking a platform when you code. Make sure you lock-in intelligently.

(Although the more I look at this, the greater the possibility that they may be working on doing just that with PDO. Still, any time you have to learn a new OM to hit a database, you've wasted a developer's time.)

Labels: ,