Update to handle upcoming releases (and features) of MongoDB driver #669

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+6 −2
Split
View
@@ -239,7 +239,6 @@ public function connect() {
$connection = "mongodb://{$login}{$host}" . ($login ? "/{$cfg['database']}" : '');
$options = array(
- 'connect' => true,
'timeout' => $cfg['timeout'],
'replicaSet' => $cfg['replicaSet']
);
@@ -249,7 +248,12 @@ public function connect() {
$options['persist'] = $persist === true ? 'default' : $persist;
}
$this->server = new Mongo($connection, $options);
-
+ $this->server->connect();
+
+ if (isset($cfg['readPreference'])) {
+ $this->server->setReadPreference($cfg['readPreference']);
@nervetattoo

nervetattoo Oct 28, 2012

Member

This should support the second argument of setReadPreference as well where you can specify preferences on server tags:

$m->setReadPreference(Mongo::RP_NEAREST, array(
    array('dc' => 'east'),
));
@preinheimer

preinheimer Oct 28, 2012

Hmm, good point. Let me play around a bit.

@preinheimer

preinheimer Oct 28, 2012

I'm not sure how notifications work on github, but please check out my comment here: #669 (comment)

+ }
+
if ($this->connection = $this->server->{$cfg['database']}) {
$this->_isConnected = true;
}