in the PHP manual, it has this example:
<?php
// pass a comma-sep开发者_Python百科arated list of server names to the constructor
$m1 = new Mongo("mongodb://sf2.example.com,ny1.example.com", array("replicaSet" => true));
// you only need to pass a single seed, the driver will derive the full list and
// find the master from this seed
$m2 = new Mongo("mongodb://ny1.example.com", array("replicaSet" => true));
?>
- However, what does $m1 return?
- If I want to find out the master, and replicates so that the master will be the one responsible to write, and one of the replicates be the read connection, what is the best way I should find out & i should do?
- Can I have persistent value different from each replica? or they have to share the same connection channel?
A little more on #2: the Mongo class automatically figures out who the primary and secondaries are, then sends writes to the primary (and reads to the secondary if you set slaveOkay).
1) $m1 and $m2 will return the Mongo (Database Connection) object, not a value as such. 2) You can find the master using $m1->isMaster(); 3) Not really sure what you mean, they have to be identical.
精彩评论