Documentation

InsertOne
in package
implements Executable

Operation for inserting a single document with the insert command.

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

Interfaces, Classes, Traits and Enums

Executable

Table of Contents

$collectionName  : string
$databaseName  : string
$document  : array<string|int, mixed>|object
$options  : array<string|int, mixed>
__construct()  : mixed
Constructs an insert command.
execute()  : InsertOneResult
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

$collectionName

private string $collectionName

$document

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

$options

private array<string|int, mixed> $options

Methods

__construct()

Constructs an insert command.

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

Supported options:

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

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

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

Parameters
$databaseName : string

Database name

$collectionName : string

Collection name

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

Document 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) : InsertOneResult
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
InsertOneResult

Search results