diff --git a/README.txt b/README.txt index ff5015d..1b81b28 100644 --- a/README.txt +++ b/README.txt @@ -83,6 +83,19 @@ Configuration Variables ), ); + Querying a slave is also possible by creating a new connection alias + and specifying slave_ok option. + + $conf['mongodb_connections'] = array( + // Connection name/alias + 'slave' => array( + 'host' => 'slave1', + // Database name + 'db' => 'drupal_default', + 'slave_ok' => TRUE, + ), + ); + #2: mongodb_debug A variable primarily for developers, mongodb_debug causes a collection diff --git a/mongodb.module b/mongodb.module index c5e4afa..69cf3b1 100644 --- a/mongodb.module +++ b/mongodb.module @@ -32,6 +32,9 @@ function mongodb($alias = 'default') { if (!isset($mongo_objects[$host][$db])) { try { $mongo = new Mongo($host, $options); + if (!empty($connection['slave_ok'])) { + $mongo->setSlaveOkay(TRUE); + } $mongo_objects[$host][$db] = $mongo->selectDB($db); $mongo_objects[$host][$db]->connection = $mongo; }