MongoDB\Driver\WriteResult::getServer

(mongodb >=1.0.0)

MongoDB\Driver\WriteResult::getServerReturns the server associated with this write result

说明

final public MongoDB\Driver\WriteResult::getServer ( void ) : MongoDB\Driver\Server

Returns the MongoDB\Driver\Server associated with this write result. This is the server that executed the MongoDB\Driver\BulkWrite.

参数

此函数没有参数。

返回值

Returns the MongoDB\Driver\Server associated with this write result.

错误/异常

范例

Example #1 MongoDB\Driver\WriteResult::getServer() example

<?php

$manager 
= new MongoDB\Driver\Manager;
$server $manager->selectServer(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY));

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);

$result $server->executeBulkWrite('db.collection'$bulk);

var_dump($result->getServer() == $server);

?>

以上例程会输出:

bool(true)
相关文章
php mongodb driver cursor returns the server associated with this cursorphp mongodb driver monitoring commandfailedevent returns the exception associated with the failed commandphp mongodb driver monitoring commandstartedevent returns the server on which the command was executedphp mongodb driver monitoring commandsucceededevent returns the server on which the command was executedphp mongodb driver exception runtimeexception returns whether an error label is associated with an exceptionphp mongodb driver server execute one or more write operations on this serverphp mongodb driver server returns the latency of this serverphp mongodb driver server returns the port on which this server is listeningphp mongodb driver server returns an array of tags describing this server in a replica setphp mongodb driver server returns an integer denoting the type of this serverphp mongodb driver writeerror returns the index of the write operation corresponding to this writeerrorphp mongodb driver exception writeexception returns the writeresult for the failed write operationphp mongodb driver writeresult returns the number of documents deletedphp mongodb driver writeresult returns the number of documents inserted excluding upserts php mongodb driver writeresult returns the number of documents selected for updatephp mongodb driver writeresult returns the number of existing documents updatedphp mongodb driver writeresult returns the server associated with this write resultphp mongodb driver writeresult returns any write concern error that occurredphp mongodb driver writeresult returns any write errors that occurredphp mongodb driver writeresult returns whether the write was acknowledged
关注编程学问公众号