Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
MongoDB\UpdateResult Class Reference

Public Member Functions

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

Member Function Documentation

◆ getMatchedCount()

MongoDB\UpdateResult::getMatchedCount ( )

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

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

See also
UpdateResult\isAcknowledged()
Return values
integer|null
Exceptions
BadMethodCallExceptionis the write result is unacknowledged

◆ getModifiedCount()

MongoDB\UpdateResult::getModifiedCount ( )

Return the number of documents that were modified.

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.

See also
UpdateResult\isAcknowledged()
Return values
integer|null
Exceptions
BadMethodCallExceptionis the write result is unacknowledged

◆ getUpsertedCount()

MongoDB\UpdateResult::getUpsertedCount ( )

Return the number of documents that were upserted.

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

See also
UpdateResult\isAcknowledged()
Return values
integer|null
Exceptions
BadMethodCallExceptionis the write result is unacknowledged

◆ getUpsertedId()

MongoDB\UpdateResult::getUpsertedId ( )

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

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.

See also
UpdateResult\isAcknowledged()
Return values
mixed|null
Exceptions
BadMethodCallExceptionis the write result is unacknowledged

◆ isAcknowledged()

MongoDB\UpdateResult::isAcknowledged ( )

Return whether this update was acknowledged by the server.

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
boolean

The documentation for this class was generated from the following file: