This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WP Db Abstraction


WP Database Abstraction is a plugin to make it possible to run WP on top of MS
SQL Server or Azure and provides two features, database access abstraction and SQL
dialect abstraction. This plugin cannot be installed or used as a regular
plugin, it must be in the “mu-plugins” directory (must use plugins) and in
addition to the plugin it contains a “drop-in” to hook into WordPress Database

Database Access Abstraction is the way you connect to the database through PHP.
This plugin allows mysql, mysqli, pdo, sqlsrv or mssql extensions to be used. PDO has support
for mssql, dblib, sqlsrv and mysql drivers. This allows
you to choose the way your WordPress installation connects to your database. You
can use the plugin and still use a Mysql Database, which is perfect if your hosting
provider does not make the mysql extension available. The flexible structure of the
plugin means that dropping in additional drivers is easy.

SQL dialect abstraction means translating from the dialect understood by Mysql
to other dialects. Currently only translation layers for T-SQL (used by Azure and SQL Server)
are provided. However this is an open source project and additional translation layers
could be added.

For help and support please see the sourceforge project

For information and tutorials please visit our blog


Known Limitations

  • This plugin must be in the “mu-plugins” directory. The db.php file “drop-in” must be in the wp-content directory. Normal plugin installation will not work.
  • Auto-update does not work for must-use plugins
  • Some plugins and themes that do not use the WP abstraction layer will break. This is contrary to WordPress API guidelines, contact the theme or plugin author.
  • Some plugins and themes may use queries that need additional translations added. Please report any you find in the sourceforge forums so the translation files can be updated. Please turn on query logging in wp-config.php and include your logs with the translation fix request.
  • Other plugins may also use a db.php drop-in. You can use both plugins, but it will requiring renaming files and adding lines
    to db.php from the plugin. See the Installation section for more details.
  • Other plugins that use db.php and extend the db class with custom behavior will break.

To Do

  • Add additional translations for PostgreSQL and Sqlite
  • Add additional drivers – pdo_sqlite, sqlite, sqlite3, pgsql, pdo_pgsql, odbc, pdo_odbc
  • Plugin specific autoupdater to mimic upgrade behavior of regular plugins
  • Administration area with the ability to view, alter, edit configuration and help with debugging issues
  • Make db.php smart enough to pick up any files prefixed with db- in the wp-content directory to help with other plugins with “drop-ins”
  • Proper error handling (no more @symbols) in database driver classes


How do I create a wp-config.php file?

For new installs – we package our own wp-config.php creator. The creation url will be at
$your_wordpress_url/wp-content/mu-plugins/wp-db-abstraction/setup-config.php The original
setup-config.php WILL be redirected after the second step if db.php is in the right place

My themes and images don’t show up when using Multisite with IIS

The rewrite rules supplied by wordpress for networking are incorrect for IIS7 and Url Rewrite

change your web.config file and replace the rewrite rule for #5 with the one below

Why is collation important when using SQL Server? How do I change the SQL Server Collation used?

By default, the SQL Server collation used by this plugin is database_default. This means
that the default collation defined by the SQL Server install will dictate the collation
used when creating the sql server tables.

If you need to use a different collation for your installation, you may define DB_COLLATE
in your wp-config.php file. For example, defining it to Cyrillic_General_BIN. Note that this
will only affect new installations of the plugin.

If you want to change the way an individual table is collated you may use the following example syntax:

ALTER TABLE wp_posts ALTER COLUMN post_content varchar(max)COLLATE Latin1_General_CI_AS



  • add all reserved words for sql server – plugins might use them
  • fixed limit regex to catch queries with ; at the end
  • fix for inserting NULL into identity columns


  • fixed ording for items in archives
  • added extra space before N prefix in strings to fix bad concatenation issues


  • packaged correct example fields_map file updated to a base 3.2.1 install
  • blocked install as anything but mu-plugin
  • fixed error messages for attempted regular plugin install
  • fixed html issues with error page
  • field maps parsed_types information cache can have a location defined in wp-config.php
  • on multisite installs, each site has it’s own database metadata cache file
  • added error if PHP database extension desired is not loaded to avoid confusing db can’t connect errors


  • additional help for installation, upgrading, and migrating
  • packaged example fields_map file updated to a base 3.2.1 install
  • translation uses N prefix for unicode data
  • DB_COLLATE obeyed properly for table creation
  • better error handling and descriptions for plugin, installation and upgrade issues


  • New method of stripping out strings before translation
  • drivers extend sql translation that extends wpdb
  • mysqli driver added
  • Drivers cleaned up and code simplified
  • Issues with sqlsrv and datetime objects, and with integrated windows auth are now fixed
  • Some translation fixes for various plugins
  • API ping is now cached
  • Error if fields_map file cannot be written to
  • Packaged example fields_map file for installations that failed


  • Fix for USING join for categories
  • mysql driver now simply extends wpdb class
  • pdo driver now provides connection exception information when WP_DEBUG is on
  • Added warning for windows users with ntwdblib and mssql to config setup


  • Changed from patch to plugin architecture.
  • Incorporated several fixes from sourceforge forums in T-SQL dialect translations

Contributors & Developers

This is open source software. The following people have contributed to this plugin.


Browse the code