free WordPress Theme

Early in the development of WordPress 3.0, we had a preliminary discussion on changing the WordPress database class (wpdb) so that it could be inherited by plugins implementing a custom database class. We had a longer discussion on the subject while together at WordCamp San Francisco. As a result, there was a small change to WordPress 3.0 which allows the wpdb class to be inherited.

In WordPress 3.1, inheriting wpdb will be the expected (but not required) behavior. The changeset for that was committed to WordPress trunk this week (trac discussion).

I’ve been working on switching SharDB over to inherit wpdb and finished up on a Development Version last night. I’m working with WordPress 3.0.1, but the dev version should work with WP 3.0 through to WP trunk. By taking advantage of inheritance, I was able to eliminate over 50% of the code in the SharDB custom DB class. All of the red in the Changeset is removed code.


  1. Hi Ron,
    I’m experimenting with setting up SharDB on my site, and I found a bug with the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE treatment in db.php.

    I posted a question, and subsequent fix for it over here, in case anyone else is needing help with that as well, but wanted to make sure I let you know about the info too.

    Thanks for the great work!

  2. Ron,

    Woud like to try this on a WP3.1 mutlisite with 250 blogs. I’ve duped the one main database, but does this modify the original database? Can it be uninstalled if I need to move the sites and original database another server?

    Thanks, Mark

    • If you have a WP 3.1 network then download the development version. It has a tool for migrating the blog tables to the appropriate shards.

      SharDB does not modify the original DB. Assuming you’re not concerned about loss of data from implementation to move, there’s no harm in removing it. You can also backup the shards and restore them to a single DB on a different server.

  3. Hello, Ron

    Is there any news on SharDB for Wp 3.1 ? The previous version 2.7.4 ( ? ) wouldn’t work when I upgraded to 3.1 so I had to copy all blogs back to the home database to straighten things out. Still have a bit of a mess and another WP installation with SharDB to go.

    Was there something I may have missed when upgrading WP ?

    SharDB is a great plugin. Thanks.


    • Hi Greg,

      I’m not sure. I don’t know of anyone using SharDB and WP-DB. I do all of my DB admin through SSH so I’m not that familiar with any of the DB admin plugins.