MongoDB\Driver\WriteResult::isAcknowledged

Returns whether the write was acknowledged

説明

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

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.

エラー / 例外

  • Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.

例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)

例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)

参考