(mongodb >=1.0.0)
MongoDB\Driver\Server::getInfo — 返回一个描述此服务器的信息数组
返回一个描述服务器的信息数组。此数组源自通过» 服务器监控获得的最新» hello命令响应。
注意:
当驱动程序连接到负载均衡器时,此方法将返回初始连接握手时后端服务器的» hello命令响应。这与其他方法(例如MongoDB\Driver\Server::getType())形成对比,后者将返回有关负载均衡器本身的信息。
此函数没有参数。
返回一个描述此服务器的信息数组。
示例 #1 MongoDB\Driver\Server::getInfo() 示例
<?php
$manager = new MongoDB\Driver\Manager('mongodb://:27017/');
$rp = new MongoDB\Driver\ReadPreference('primary');
$server = $manager->selectServer($rp);
var_dump($server->getInfo());
?>上面的示例将输出类似以下内容
array(23) {
["helloOk"]=>
bool(true)
["topologyVersion"]=>
array(2) {
["processId"]=>
object(MongoDB\BSON\ObjectId)#4 (1) {
["oid"]=>
string(24) "617b6d696a3a89d2f77e6df0"
}
["counter"]=>
int(6)
}
["hosts"]=>
array(1) {
[0]=>
string(15) "localhost:27017"
}
["setName"]=>
string(3) "rs0"
["setVersion"]=>
int(1)
["ismaster"]=>
bool(true)
["secondary"]=>
bool(false)
["primary"]=>
string(15) "localhost:27017"
["me"]=>
string(15) "localhost:27017"
["electionId"]=>
object(MongoDB\BSON\ObjectId)#5 (1) {
["oid"]=>
string(24) "7fffffff0000000000000001"
}
["lastWrite"]=>
array(4) {
["opTime"]=>
array(2) {
["ts"]=>
object(MongoDB\BSON\Timestamp)#6 (2) {
["increment"]=>
string(1) "1"
["timestamp"]=>
string(10) "1635478989"
}
["t"]=>
int(1)
}
["lastWriteDate"]=>
object(MongoDB\BSON\UTCDateTime)#7 (1) {
["milliseconds"]=>
string(13) "1635478989000"
}
["majorityOpTime"]=>
array(2) {
["ts"]=>
object(MongoDB\BSON\Timestamp)#8 (2) {
["increment"]=>
string(1) "1"
["timestamp"]=>
string(10) "1635478989"
}
["t"]=>
int(1)
}
["majorityWriteDate"]=>
object(MongoDB\BSON\UTCDateTime)#9 (1) {
["milliseconds"]=>
string(13) "1635478989000"
}
}
["maxBsonObjectSize"]=>
int(16777216)
["maxMessageSizeBytes"]=>
int(48000000)
["maxWriteBatchSize"]=>
int(100000)
["localTime"]=>
object(MongoDB\BSON\UTCDateTime)#10 (1) {
["milliseconds"]=>
string(13) "1635478992136"
}
["logicalSessionTimeoutMinutes"]=>
int(30)
["connectionId"]=>
int(3)
["minWireVersion"]=>
int(0)
["maxWireVersion"]=>
int(13)
["readOnly"]=>
bool(false)
["ok"]=>
float(1)
["$clusterTime"]=>
array(2) {
["clusterTime"]=>
object(MongoDB\BSON\Timestamp)#11 (2) {
["increment"]=>
string(1) "1"
["timestamp"]=>
string(10) "1635478989"
}
["signature"]=>
array(2) {
["hash"]=>
object(MongoDB\BSON\Binary)#12 (2) {
["data"]=>
string(20) ""
["type"]=>
int(0)
}
["keyId"]=>
int(0)
}
}
["operationTime"]=>
object(MongoDB\BSON\Timestamp)#13 (2) {
["increment"]=>
string(1) "1"
["timestamp"]=>
string(10) "1635478989"
}
}
| 版本 | 描述 |
|---|---|
| PECL mongodb 1.11.0 | 当驱动程序连接到负载均衡器时,此方法将返回初始连接握手时后端服务器的hello命令响应。 |