Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

WordPress is undoubtely very customizable using plugins, but every customization possibility surely has limits defined by the underlying architecture.

For those familiar with WP architecture and source code:

What would be the effort required to customize the data layer used by WP to use another data store (e.g. files (or another database system) instead of MySQL?). Is WordPress architecture layered in the sense of having the possibility to switch layers? The UI layer is apparently very easy to switch (any theme does this), but how about other layers, namely the data layer?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

Wordpress is not designed to have a replace-able database layer. Computer Science has some different concepts in it's chest to deal with different databases in the same application on different level of abstraction, Wordpress does not tend to make use of any of such. To say it in more simple words: Not at all.

But wordpress offers the ability to replace it's own code with some other code, for example the whole database class. That is not always (read: normally) enough to replace the whole database layer but helps tinkering. The WPDB class replacing HyperDB for example does not add a new database layer in full, but handles multiple MySQL servers instead of one, which is a well known example (this is considered bad practice to do with PHP, there are better ways, but it's a good example what can be done).

Next to replacing the database class, Wordpress has the ability that even more code can be replaced and you can completely change it, e.g. creating an own distribution that takes care of everything regarding the database layer on it's own.

If you want to see a real life example on how to replace the whole database layer, so to make wordpress use a totally different type of database server (here: MSSQL instead of the hardcoded MySQL), you find a full distribution and a patch here:

WordPress on SQL Server Distro & Patch

It's free software you can study how such a database layer can be implemented, the website provides more information about that topic as well.

Tip: Don't fight Wordpress. Stick to MySQL and that's it. Otherwise look for something else better designed to fit your needs. Just take the right tool for the job.

share|improve this answer
add comment

It's possible: see the HyperDB replacement for wpdb. HyperDB adds partitioning and replication to WordPress. Partitioning works by connecting to multiple databases and using the table name to determine which database should run the query.

In the end, $wpdb just gets a SQL query, and it's free to do what it wants with the data within that query. HyperDB queries MySQL just like the original wpdb class. Extending that to different databases would require modifying any non-compliant queries before they are executed. If your data store doesn't accept SQL at all, you would have to translate the incoming query to whatever other API you're using. Anything is possible with enough time and effort, but it sounds like a pretty miserable undertaking to me. ;)

share|improve this answer
add comment

Just found this Codex page which sums it up nicely, including overview of solutions proposed and/or planned by the people who develop WordPress. Let's see how it comes out.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.