Skip to content

Instantly share code, notes, and snippets.

@solisoft
Created November 20, 2011 02:37
Show Gist options
  • Save solisoft/1379730 to your computer and use it in GitHub Desktop.
Save solisoft/1379730 to your computer and use it in GitHub Desktop.
PHP replicaSet connection
<?php
// connecting to mongood.com cluster
$m = new Mongo("mongodb://mongo1.mongood.com:27017,mongo2.mongood.com:27017,mongo3.mongood.com:27017", array("replicaSet" => "cluster"));
var_dump($m);
$db = $m->selectDB('my_database');
$db->authenticate("my_login", "my_password");
$collection = new MongoCollection($db, 'my_collection');
$cursor = $collection->find();
foreach ($cursor as $doc) {
var_dump($doc);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment