[wp-hackers] Hyperdb - getting currently available write connection

Christian Foster christian.foster at gmail.com
Tue Nov 30 17:15:11 UTC 2010


Hi,

We have a need to use an external script that uses PDO to interact
with the database.

We are also using HyperDB to access a master/slave configuration
between 2 servers.

Does anyone know how I can let the external script have access to the
currently available write connection (i.e. if master goes down slave
goes to write - but I need the username, password, host and port of
the currently available write server)?

I can see there are lots of variables in $wpdb - especially
$wpdb->dbh2host['global__w'] - which gives me the server name and port
but not login credentials (which I think are available elsewhere in
another array.

Cheers,

Chris.


More information about the wp-hackers mailing list