MongoClient::getHosts
(PECL mongo >=1.3.0)
MongoClient::getHosts — Updates status for all associated hosts
This extension that defines this method is deprecated. Instead, the MongoDB extension should be used. Alternatives to this method include:
Описание
This method is only useful with a connection to a replica set. It returns the status of all of the hosts in the set. Without a replica set, it will just return an array with one element containing the host that you are connected to.
See the query section of this manual for information on distributing reads to secondaries.
Список параметров
У этой функции нет параметров.
Возвращаемые значения
Returns an array of information about the hosts in the set. Includes each host's hostname, its health (1 is healthy), its state (1 is primary, 2 is secondary, 0 is anything else), the amount of time it took to ping the server, and when the last ping occurred. For example, on a three-member replica set, it might look something like:
array(3) { ["A:27017"]=> array(4) { ["host"]=> "A" ["port"]=> 27017 ["health"]=> int(1) ["state"]=> int(2) ["ping"]=> int(369) ["lastPing"]=> int(1309470644) } ["B:27017"]=> array(4) { ["host"]=> "B" ["port"]=> 27017 ["health"]=> int(1) ["state"]=> int(1) ["ping"]=> int(139) ["lastPing"]=> int(1309470644) } ["C:27017"]=> array(4) { ["host"]=> "C" ["port"]=> 27017 ["health"]=> int(1) ["state"]=> int(2) ["ping"]=> int(1012) ["lastPing"]=> int(1309470644) } }
Список изменений
Версия | Описание |
---|---|
1.2.10 |
Support for non-replicasets was added. The returned array elements now also include the hostname and port. |
Смотрите также
- MongoClient::getConnections() - Return info about all open connections
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- MongoDB
- Базовые классы
- Функция MongoClient::close() - Closes this connection
- Функция MongoClient::connect() - Connects to a database server
- Функция MongoClient::__construct() - Creates a new database connection object
- Функция MongoClient::dropDB() - Drops a database [deprecated]
- Функция MongoClient::__get() - Gets a database
- Функция MongoClient::getConnections() - Return info about all open connections
- Функция MongoClient::getHosts() - Updates status for all associated hosts
- Функция MongoClient::getReadPreference() - Get the read preference for this connection
- Функция MongoClient::getWriteConcern() - Get the write concern for this connection
- Функция MongoClient::killCursor() - Kills a specific cursor on the server
- Функция MongoClient::listDBs() - Lists all of the databases available.
- Функция MongoClient::selectCollection() - Gets a database collection
- Функция MongoClient::selectDB() - Gets a database
- Функция MongoClient::setReadPreference() - Set the read preference for this connection
- Функция MongoClient::setWriteConcern() - Set the write concern for this connection
- Функция MongoClient::__toString() - String representation of this connection
Коментарии
404 Not Found