Returns whether the write was acknowledged

- « MongoDB\Driver\BulkWriteCommandResult::getUpsertedCount

- MongoDB\BSON »

- PHP Manual
- MongoDB\Driver\BulkWriteCommandResult
- Returns whether the write was acknowledged

# MongoDB\Driver\BulkWriteCommandResult::isAcknowledged

(mongodb >=2.1.0)

MongoDB\Driver\BulkWriteCommandResult::isAcknowledged — Returns whether the write was acknowledged

### Description

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

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

### Parameters

This function has no parameters.

### Return Values

Returns `true` if the write was acknowledged, and `false` otherwise.

### Errors/Exceptions

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

### Examples

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

    <?php

    $manager = new MongoDB\Driver\Manager;

    $bulk = new MongoDB\Driver\BulkWriteCommand;
    $bulk->insertOne('db.coll', ['x' => 1]);

    $result = $manager->executeBulkWriteCommand($bulk);

    var_dump($result->isAcknowledged());

    ?>

The above example will output:

    bool(true)

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

    <?php

    $manager = new MongoDB\Driver\Manager;

    $bulk = new MongoDB\Driver\BulkWriteCommand(['ordered' => false]);
    $bulk->insertOne('db.coll', ['x' => 1]);

    $writeConcern = new MongoDB\Driver\WriteConcern(0);

    $result = $manager->executeBulkWriteCommand($bulk, ['writeConcern' => $writeConcern]);

    var_dump($result->isAcknowledged());

    ?>

The above example will output:

    bool(false)

### See Also

- MongoDB\Driver\WriteConcern
- » Write Concern reference