MongoDB
Table of Contents
Namespaces
Classes
- BulkWriteResult
- Result class for a bulk write operation.
- ChangeStream
- Iterator for a change stream.
- Client
- ClientBulkWrite
- Collection
- Database
- DeleteResult
- Result class for a delete operation.
- InsertManyResult
- Result class for a multi-document insert operation.
- InsertOneResult
- Result class for a single-document insert operation.
- UpdateResult
- Result class for an update operation.
Functions
- add_logger() : void
- Registers a PSR-3 logger to receive log messages from the driver/library.
- remove_logger() : void
- Unregisters a PSR-3 logger.
- object() : stdClass
- Create a new stdClass instance with the provided properties.
- with_transaction() : void
- Execute a callback within a transaction in the given session
Functions
add_logger()
Registers a PSR-3 logger to receive log messages from the driver/library.
add_logger(LoggerInterface $logger) : void
Calling this method again with a logger that has already been added will have no effect.
Parameters
- $logger : LoggerInterface
remove_logger()
Unregisters a PSR-3 logger.
remove_logger(LoggerInterface $logger) : void
Calling this method with a logger that has not been added will have no effect.
Parameters
- $logger : LoggerInterface
object()
Create a new stdClass instance with the provided properties.
object(mixed ...$values) : stdClass
Use named arguments to specify the property names. object( property1: value1, property2: value2 )
If property names contain a dot or a dollar characters, use array unpacking syntax. object( ...[ 'author.name' => 1, 'array.$' => 1 ] )
Parameters
- $values : mixed
Tags
Return values
stdClasswith_transaction()
Execute a callback within a transaction in the given session
with_transaction(Session $session, callable $callback[, array<string|int, mixed> $transactionOptions = [] ]) : void
This helper takes care of retrying the commit operation or the entire transaction if an error occurs.
If the commit fails because of an UnknownTransactionCommitResult error, the commit is retried without re-invoking the callback. If the commit fails because of a TransientTransactionError, the entire transaction will be retried. In this case, the callback will be invoked again. It is important that the logic inside the callback is idempotent.
In case of failures, the commit or transaction are retried until 120 seconds from the initial call have elapsed. After that, no retries will happen and the helper will throw the last exception received from the driver.
Parameters
- $session : Session
-
A session object as retrieved by Client::startSession
- $callback : callable
-
A callback that will be invoked within the transaction
- $transactionOptions : array<string|int, mixed> = []
-
Additional options that are passed to Session::startTransaction