在PHP manual ,它有这个例子:
<?php
// pass a comma-separated 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));
?>
最佳答案
关于 #2 的更多信息:Mongo 类自动确定谁是主节点和从节点,然后向主节点发送写入(如果您设置了 slaveOkay,则向从节点发送读取)。
关于php - PHP Mongo 问题列表 : What does _construct return when replicaSet is true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5559474/