PHP Mongo问题列表:当replicaSet为true时,\ u构造返回什么?

PHP Mongo问题列表:当replicaSet为true时,\ u构造返回什么?,php,mongodb,Php,Mongodb,在中,它有以下示例: <?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 f

在中,它有以下示例:

<?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));

?>

  • 然而,m1美元的回报是什么
  • 如果我想找到主机,并进行复制,以便主机将负责写入,其中一个复制是读取连接,那么我应该找到的最佳方法是什么&我应该怎么做
  • 每个复制副本的持久值是否不同?或者他们必须共享同一个连接通道
  • (一) $m1和$m2将返回Mongo(数据库连接)对象,而不是其本身的值。 2) 您可以使用$m1->isMaster()找到master; 3)
    不太清楚您的意思,它们必须是相同的。

    关于#2:Mongo类会自动找出主对象和辅助对象,然后向主对象发送写操作(如果设置了slaveOK,则向辅助对象发送读操作)。

    $m1
    是Mongo类创建的对象。它将返回对象本身。$m1是主对象吗?或者我需要使用$isMaster()?3) 谢谢。明白了吗?顺便说一下,没有isMaster()方法,您可以运行
    $m1->someDb->命令(数组(“isMaster”=>1))