Documentation

UpdateResult
in package

Result class for an update operation.

Table of Contents

Properties

$writeResult  : WriteResult

Methods

__construct()  : mixed
getMatchedCount()  : int
Return the number of documents that were matched by the filter.
getModifiedCount()  : int
Return the number of documents that were modified.
getUpsertedCount()  : int
Return the number of documents that were upserted.
getUpsertedId()  : mixed
Return the ID of the document inserted by an upsert operation.
isAcknowledged()  : bool
Return whether this update was acknowledged by the server.

Properties

Methods

__construct()

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

getMatchedCount()

Return the number of documents that were matched by the filter.

public getMatchedCount() : int

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

Tags
see
UpdateResult::isAcknowledged()
throws
LogicException

if the write result is unacknowledged

Return values
int

getModifiedCount()

Return the number of documents that were modified.

public getModifiedCount() : int

This value is undefined (i.e. null) if the write executed as a legacy operation instead of command.

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

Tags
see
UpdateResult::isAcknowledged()
throws
LogicException

if the write result is unacknowledged

Return values
int

getUpsertedCount()

Return the number of documents that were upserted.

public getUpsertedCount() : int

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

Tags
see
UpdateResult::isAcknowledged()
throws
LogicException

if the write result is unacknowledged

Return values
int

getUpsertedId()

Return the ID of the document inserted by an upsert operation.

public getUpsertedId() : mixed

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

This value is undefined (i.e. null) if an upsert did not take place.

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

Tags
see
UpdateResult::isAcknowledged()
throws
LogicException

if the write result is unacknowledged

isAcknowledged()

Return whether this update was acknowledged by the server.

public isAcknowledged() : bool

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

Return values
bool

        
On this page

Search results