Documentation

InsertOneResult
in package

Result class for a single-document insert operation.

Table of Contents

Properties

$insertedId  : mixed
$writeResult  : WriteResult

Methods

__construct()  : mixed
getInsertedCount()  : int
Return the number of documents that were inserted.
getInsertedId()  : mixed
Return the inserted document's ID.
isAcknowledged()  : bool
Return whether this insert was acknowledged by the server.

Properties

Methods

__construct()

public __construct(WriteResult $writeResult, mixed $insertedId) : mixed
Parameters
$writeResult : WriteResult
$insertedId : mixed

getInsertedCount()

Return the number of documents that were inserted.

public getInsertedCount() : int

This method should only be called if the write was acknowledged.

Tags
see
InsertOneResult::isAcknowledged()
throws
LogicException

if the write result is unacknowledged

Return values
int

getInsertedId()

Return the inserted document's ID.

public getInsertedId() : mixed

If the document had an ID prior to inserting (i.e. the driver did not need to generate an ID), this will contain its "_id". Any driver-generated ID will be a MongoDB\BSON\ObjectId instance.

isAcknowledged()

Return whether this insert was acknowledged by the server.

public isAcknowledged() : bool

If the insert was not acknowledged, other fields from the WriteResult (e.g. insertedCount) will be undefined.

If the insert was not acknowledged, other fields from the WriteResult (e.g. insertedCount) will be undefined and their getter methods should not be invoked.

Return values
bool

        
On this page

Search results