Home > Backend Development > PHP Tutorial > PHP支持Mongodb副本集联接吗

PHP支持Mongodb副本集联接吗

WBOY
Release: 2016-06-13 12:04:07
Original
1688 people have browsed it

PHP支持Mongodb副本集连接吗?
如题。
因为只有对一个库的权限,所以指定了dbname
连接如下:
$con = new Mongo("mongodb://user:[email protected]:27010,192.168.0.2:27010,192.168.0.3:27010/dbname");

现在报错了。
不知道PHP支持副本集连接吗?
常规来说,如果第一个ip连接上的话,那后面两个会忽略,如果第一个ip连不上的话,会自动连第二个或第三个。可是现在为什么有时候会报错?



------解决方案--------------------
$this->connection->setSlaveOkay(true);

如果是集群还得设置下主从。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template