(mongodb >=1.0.0)
MongoDB\Driver\WriteResult::isAcknowledged — Returns whether the write was acknowledged
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)