(mongodb >=1.0.0)
MongoDB\Driver\WriteResult::isAcknowledged — 返回写入是否已确认
如果写入已确认,则其他计数字段将在此 MongoDB\Driver\WriteResult 对象上可用。
此函数没有参数。
示例 #1 MongoDB\Driver\WriteResult::isAcknowledged() 使用已确认的写入关注
<?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)
示例 #2 MongoDB\Driver\WriteResult::isAcknowledged() 使用未确认的写入关注
<?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)