[HyperDB] Multiple Database Setup and Read

Aris Blevins aris at goteama.com
Sat Mar 12 23:39:14 UTC 2011

Hi there,

I have some clients that have a main Wordpress install and now are  
hoping to add two mini-sites that draw specific posts from the main  
site. My hope was to set up two separate Wordpress installs and use  
HyperDB to allow me to pull from the main database as needed.

I have add the databases as follows:

	'host'     => 'mysql.german.site',     // If port is other than 3306,  
use host:port.
	'user'     => 'username',
	'password' => 'password',
	'name'     => 'german_db',
	'dataset'  => 'global'

	'host'     => 'mysql.site',     // If port is other than 3306, use  
	'user'     => 'username',
	'password' => 'password',
	'name'     => 'main_db',
	'write'    => 0,
	'read'     => 1,
	'dataset'  => 'main'

The first database is for the site that will highlight german content  
from the main site.

The second is the main database - I want to be able to only read from  
this site.

The two databases have different table prefixes (ge_ for german and  
wp_ for the main site)

I had hoped that this would work (as a test):

global $wpdb;

$fivesdrafts = $wpdb->get_results("SELECT post_title FROM $wpdb->posts  
WHERE post_status = 'published'");

foreach ($fivesdrafts as $fivesdraft) {
	echo $fivesdraft->post_title;

But I get nothing on the page here. Any ideas? The final goal here is  
to pull in all published posts from a specific category and list them  
on this page.

Any help would be appreciated, let me know if I need to post more  


More information about the HyperDB mailing list