array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'mongodb-driver-manager.getservers.php', 1 => 'MongoDB\\Driver\\Manager::getServers', 2 => 'Return the servers to which this manager is connected', ), 'up' => array ( 0 => 'class.mongodb-driver-manager.php', 1 => 'MongoDB\\Driver\\Manager', ), 'prev' => array ( 0 => 'mongodb-driver-manager.getreadpreference.php', 1 => 'MongoDB\\Driver\\Manager::getReadPreference', ), 'next' => array ( 0 => 'mongodb-driver-manager.getwriteconcern.php', 1 => 'MongoDB\\Driver\\Manager::getWriteConcern', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mongodb/mongodb/driver/manager/getservers.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(mongodb >=1.0.0)
MongoDB\Driver\Manager::getServers — Return the servers to which this manager is connected
Returns an array of MongoDB\Driver\Server instances to which this manager is connected.
Зауваження: Since the driver connects to the database lazily, this method may return an empty array if called before executing an operation on the MongoDB\Driver\Manager.
У цієї функції немає параметрів.
Returns an array of MongoDB\Driver\Server instances to which this manager is connected.
Приклад #1 MongoDB\Driver\Manager::getServers() example
<?php
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
/* The driver connects to the database server lazily, so Manager::getServers()
* may initially return an empty array. */
var_dump($manager->getServers());
$command = new MongoDB\Driver\Command(['ping' => 1]);
$manager->executeCommand('db', $command);
var_dump($manager->getServers());
?>Поданий вище приклад виведе щось схоже на:
array(0) {
}
array(1) {
[0]=>
object(MongoDB\Driver\Server)#3 (10) {
["host"]=>
string(9) "localhost"
["port"]=>
int(27017)
["type"]=>
int(1)
["is_primary"]=>
bool(false)
["is_secondary"]=>
bool(false)
["is_arbiter"]=>
bool(false)
["is_hidden"]=>
bool(false)
["is_passive"]=>
bool(false)
["last_hello_response"]=>
array(8) {
["isWritablePrimary"]=>
bool(true)
["maxBsonObjectSize"]=>
int(16777216)
["maxMessageSizeBytes"]=>
int(48000000)
["maxWriteBatchSize"]=>
int(1000)
["localTime"]=>
object(MongoDB\BSON\UTCDateTime)#4 (1) {
["milliseconds"]=>
int(1447267964517)
}
["maxWireVersion"]=>
int(3)
["minWireVersion"]=>
int(0)
["ok"]=>
float(1)
}
["round_trip_time"]=>
int(554)
}
}