Documentation

InsertMany
in package
implements Executable

Operation for inserting multiple documents with the insert command.

Tags
see
Collection::insertMany()
see
http://docs.mongodb.org/manual/reference/command/insert/

Interfaces, Classes, Traits and Enums

Executable

Table of Contents

$collectionName  : string
$databaseName  : string
$documents  : array<string|int, object>|array<string|int, array<string|int, mixed>>
$options  : array<string|int, mixed>
__construct()  : mixed
Constructs an insert command.
execute()  : InsertManyResult
Execute the operation.
createBulkWriteOptions()  : array<string|int, mixed>
Create options for constructing the bulk write.
createExecuteOptions()  : array<string|int, mixed>
Create options for executing the bulk write.

Properties

$documents

private array<string|int, object>|array<string|int, array<string|int, mixed>> $documents

$options

private array<string|int, mixed> $options

Methods

__construct()

Constructs an insert command.

public __construct(string $databaseName, string $collectionName, array<string|int, array<string|int, mixed>>|array<string|int, object> $documents[, array<string|int, mixed> $options = [] ]) : mixed

Supported options:

  • bypassDocumentValidation (boolean): If true, allows the write to circumvent document level validation.

  • ordered (boolean): If true, when an insert fails, return without performing the remaining writes. If false, when a write fails, continue with the remaining writes, if any. The default is true.

  • session (MongoDB\Driver\Session): Client session.

  • writeConcern (MongoDB\Driver\WriteConcern): Write concern.

Parameters
$databaseName : string

Database name

$collectionName : string

Collection name

$documents : array<string|int, array<string|int, mixed>>|array<string|int, object>

List of documents to insert

$options : array<string|int, mixed> = []

Command options

Tags
throws
InvalidArgumentException

for parameter/option parsing errors

Return values
mixed

execute()

Execute the operation.

public execute(Server $server) : InsertManyResult
Parameters
$server : Server
Tags
see
Executable::execute()
throws
UnsupportedException

if write concern is used and unsupported

throws
RuntimeException

for other driver errors (e.g. connection errors)

Return values
InsertManyResult

Search results