php8.5
Home/ Manual/ driver / server/ MongoDB\Driver\Server::executeBulkWrite

MongoDB\Driver\Server::executeBulkWrite

PHP function Edit on GitHub ✎

(mongodb >=1.0.0)

Execute one or more write operations on this server

Description

MongoDB\Driver\Server::executeBulkWrite(string $namespace, MongoDB\Driver\BulkWrite $bulk, array|null $options = null): MongoDB\Driver\WriteResult

Executes one or more write operations on this server.

A MongoDB\Driver\BulkWrite can be constructed with one or more write operations of varying types (e.g. updates, deletes, and inserts). The driver will attempt to send operations of the same type to the server in as few requests as possible to optimize round trips.

The default value for the "writeConcern" option will be inferred from an active transaction (indicated by the "session" option), followed by the connection URI.

Parameters

options
OptionTypeDescription

Return Values Writeresult

Errors/Exceptions

  • Throws MongoDB\Driver\Exception\InvalidArgumentException if bulk does not contain any write operations.
  • Throws MongoDB\Driver\Exception\InvalidArgumentException if bulk has already been executed. MongoDB\Driver\BulkWrite objects may not be executed multiple times.
  • Throws MongoDB\Driver\Exception\RuntimeException on other errors.

Changelog

VersionDescription
PECL mongodb 2.0.0The options parameter no longer accepts a MongoDB\Driver\WriteConcern instance.
PECL mongodb 1.21.0Passing a MongoDB\Driver\WriteConcern object as options is deprecated and will be removed in 2.0.
PECL mongodb 1.4.4MongoDB\Driver\Exception\InvalidArgumentException will be thrown if the "session" option is used in combination with an unacknowledged write concern.
PECL mongodb 1.4.0The third parameter is now an options array. For backwards compatibility, this parameter will still accept a MongoDB\Driver\WriteConcern object.
PECL mongodb 1.3.0MongoDB\Driver\Exception\InvalidArgumentException is now thrown if bulk does not contain any write operations. Previously, a MongoDB\Driver\Exception\BulkWriteException was thrown.

Notes Write

See Also

Source: reference/mongodb/mongodb/driver/server/executebulkwrite.xml · from the official PHP manual (php/doc-en)