MDB2 is an abstraction layer maintained as part of the PEAR project. It is compatible with php4. PDO is, as you say, PHP5 only.
the reason for supporting both would be to provide compatibility for PHP4 and PHP5 across a broad church of databases. when MDB2 finally supports PDO then the native support for PDO in the proposed wrapper could be dropped. The advantage of PDO over MDB2 is that (i) it’s compiled in, so fast; (ii) it supports sqlite3 databases whereas MDB2 currently only supports sqlite2.
the advantage/requirement for sqlite support is to make the blog database easily backedup(able) and portable. sqlite databases are a single file in the filesystem. It also potentially extends the availability of wordpress to hosts or hosting plans that don’t include mysql or for which the mysql size limit is crazy-low (i.e. 1and1). THat’s a secondary benefit though, to my mind.
the process is a bit more complex than you were alluding. the actual abstraction of wp-db is easy. what i would be looking to do is to disassemble the queries on the fly and undo the escaping and quoting that is present in the existing query. then reassemble the query with parameter placeholders
Select * from table where id=?
and use prepare … execute methods to perform the queries and natively protect from sql injection attacks.
The complexity is in the sql parsing engine. The closest that I have found ‘out of the box’ is maintained in PEAR (SQL_Parser) but it has bugs (doesn’t recognise HAVING clauses or some functions) that are non-trivial to fix. So i’m still searching for a good parsing engine before jumping off the deep end and writing my own lexer, parser and compiler.
If anyone knows of a good engine (written in php) that is available under GNU GPL then please provide a link.
thanks
Justin Adie