MongoDB\Driver\WriteResult::isAcknowledged

(mongodb >=1.0.0)

MongoDB\Driver\WriteResult::isAcknowledgedReturns whether the write was acknowledged

说明

final public MongoDB\Driver\WriteResult::isAcknowledged ( void ) : bool

If the write is acknowledged, other count fields will be available on the MongoDB\Driver\WriteResult object.

参数

此函数没有参数。

返回值

Returns TRUE if the write was acknowledged, and FALSE otherwise.

错误/异常

范例

Example #1 MongoDB\Driver\WriteResult::isAcknowledged() with acknowledged write concern

<?php

$manager 
= new MongoDB\Driver\Manager;

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

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

var_dump($result->isAcknowledged());

?>

以上例程会输出:

bool(true)

Example #2 MongoDB\Driver\WriteResult::isAcknowledged() with unacknowledged write concern

<?php

$manager 
= new MongoDB\Driver\Manager;

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

$result $manager->executeBulkWrite('db.collection'$bulk, new MongoDB\Driver\WriteConcern(0));

var_dump($result->isAcknowledged());

?>

以上例程会输出:

bool(false)
相关文章
php mongodb driver the mongodb driver writeresult classphp mongodb driver bulkwrite count number of write operations in the bulkphp mongodb driver monitoring commandfailedevent returns the server on which the command was executedphp mongodb driver monitoring commandstartedevent returns the database on which the command was executedphp 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 writeconcern returns the writeconcern s w optionphp 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 the number of documents inserted by an upsertphp mongodb driver writeresult returns an array of identifiers for upserted documentsphp 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
关注编程学问公众号