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));
?>
不太清楚您的意思,它们必须是相同的。关于#2:Mongo类会自动找出主对象和辅助对象,然后向主对象发送写操作(如果设置了slaveOK,则向辅助对象发送读操作)。
$m1
是Mongo类创建的对象。它将返回对象本身。$m1是主对象吗?或者我需要使用$isMaster()?3) 谢谢。明白了吗?顺便说一下,没有isMaster()方法,您可以运行$m1->someDb->命令(数组(“isMaster”=>1))
。