array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'mongodb-driver-cursor.getserver.php', 1 => 'MongoDB\\Driver\\Cursor::getServer', 2 => 'Returns the server associated with this cursor', ), 'up' => array ( 0 => 'class.mongodb-driver-cursor.php', 1 => 'MongoDB\\Driver\\Cursor', ), 'prev' => array ( 0 => 'mongodb-driver-cursor.getid.php', 1 => 'MongoDB\\Driver\\Cursor::getId', ), 'next' => array ( 0 => 'mongodb-driver-cursor.isdead.php', 1 => 'MongoDB\\Driver\\Cursor::isDead', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mongodb/mongodb/driver/cursor/getserver.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\Cursor::getServer — Returns the server associated with this cursor
Returns the MongoDB\Driver\Server associated with this cursor. This is the server that executed the MongoDB\Driver\Query or MongoDB\Driver\Command.
У цієї функції немає параметрів.
Returns the MongoDB\Driver\Server associated with this cursor.
Приклад #1 MongoDB\Driver\Cursor::getServer() example
<?php
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$query = new MongoDB\Driver\Query([]);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$manager->executeBulkWrite('db.collection', $bulk);
$cursor = $manager->executeQuery('db.collection', $query);
var_dump($cursor->getServer());
?>Поданий вище приклад виведе щось схоже на:
object(MongoDB\Driver\Server)#5 (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)#6 (1) {
["milliseconds"]=>
int(1446505367907)
}
["maxWireVersion"]=>
int(3)
["minWireVersion"]=>
int(0)
["ok"]=>
float(1)
}
["round_trip_time"]=>
int(584)
}