[wp-hackers] alternative database support

Sam Angove sam at rephrase.net
Mon Oct 9 02:49:30 GMT 2006

On 10/8/06, Matt Mullenweg <m at mullenweg.com> wrote:
> WordPress doesn't do anything that fancy with the database. There is
> feature-comparable software driven purely by text files.

OTOH, that ought to make DB-independence easy. :P

> 1) Infinitely more complex testing (we have enough trouble with W/LAMP)

*cough* Unit tests. *cough*

> Lastly, as someone pointed out, $wpdb is structured as such that all the
> hard work could be done as a $wpdb replacement with some clever regex,
> with no core modifications. (Aka, a plugin.)

There might still be other problems: does `dbDelta()` need to be fully

The dynamic query replacement could be better. If WordPress made use
of prepared statements, for example, frequently-used queries could be
substituted with a single lookup in a hash table.

I mean, something like this (PDO style):

    $stmt = $wpdb->prepare("SELECT post_status, comment_status
                            FROM :post_table WHERE ID = :comment_post_ID");

    $stmt->bindParam(':comment_post_ID', $comment_post_ID);
    $stmt->bindParam(':post_table', $wpdb->posts);

    $status = $stmt->execute();

The query sent to `prepare()` could be a key in a MySQL->SomeOtherSQL
map array -- much faster. That's on top of the other benefits of
prepared statements, obviously, like automatic escaping and repeated

More information about the wp-hackers mailing list