Permalink
Browse files

change replicaset setting

  • Loading branch information...
1 parent c93208b commit d8032f0a9d80522a2490f0322b017de90670a349 @ichikaway committed Aug 24, 2011
Showing with 7 additions and 6 deletions.
  1. +6 −5 README.markdown
  2. +1 −1 models/datasources/mongodb_source.php
View
@@ -35,15 +35,16 @@ To use this DB driver, install (obviously) and define a db source such as follow
/* optional auth fields
'login' => 'mongo',
'password' => 'awesomeness',
- 'replicaset' => array('host' => 'mongodb://hoge:hogehoge@localhost:27021,localhost:27022/blog', 'name' => 'myRepl'),
+ 'replicaset' => array('host' => 'mongodb://hoge:hogehoge@localhost:27021,localhost:27022/blog',
+ 'options' => array('replicaSet' => 'myRepl')
+ ),
*/
);
-If set 'replicaset' key, it doesn't use host, port, login, password keys.
-Please set all connection info in replicaset host and set your replicaset name in replicaset name.
-This example shows connecting to localhost:27021 or localhost:27022 with auth info(id:hoge, password:hogehoge),
-and using blog database.
+More detail of replicaset in wiki:
+https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-connect-to-replicaset-servers
+
Model files need to have mongoSchema property - or make use of the schemaless behavior.
@@ -179,7 +179,7 @@ public function connect() {
$host = $this->createConnectionName($this->config, $this->_driverVersion);
if (isset($this->config['replicaset']) && count($this->config['replicaset']) === 2) {
- $this->connection = new Mongo($this->config['replicaset']['host'], $this->config['replicaset']['name']);
+ $this->connection = new Mongo($this->config['replicaset']['host'], $this->config['replicaset']['options']);
} else if ($this->_driverVersion >= '1.2.0') {
$this->connection = new Mongo($host, array("persist" => $this->config['persistent']));
} else {

0 comments on commit d8032f0

Please sign in to comment.