Created
November 20, 2011 02:37
-
-
Save solisoft/1379730 to your computer and use it in GitHub Desktop.
PHP replicaSet connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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