Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

(no description)

File Size: 425 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: Client  - X-Ref

__construct(?string $uri = null, array $uriOptions = [], array $driverOptions = [])   X-Ref
Constructs a new Client instance.

This is the preferred class for connecting to a MongoDB server or
cluster of servers. It serves as a gateway for accessing individual
databases and collections.

Supported driver-specific options:

* typeMap (array): Default type map for cursors and BSON documents.

Other options are documented in MongoDB\Driver\Manager::__construct().

param: string|null $uri           MongoDB connection string. If none is provided, this defaults to self::DEFAULT_URI.
param: array       $uriOptions    Additional connection string options
param: array       $driverOptions Driver-specific options

__debugInfo()   X-Ref
Return internal properties for debugging purposes.

return: array

__get(string $databaseName)   X-Ref
Select a database.

Note: databases whose names contain special characters (e.g. "-") may
be selected with complex syntax (e.g. $client->{"that-database"}) or
{@link selectDatabase()}.

param: string $databaseName Name of the database to select
return: Database

__toString()   X-Ref
Return the connection string (i.e. URI).

return: string

createClientEncryption(array $options)   X-Ref
Returns a ClientEncryption instance for explicit encryption and decryption

param: array $options Encryption options
return: ClientEncryption

dropDatabase(string $databaseName, array $options = [])   X-Ref
Drop a database.

param: string $databaseName Database name
param: array  $options      Additional options
return: array|object Command result document

getManager()   X-Ref
Return the Manager.

return: Manager

getReadConcern()   X-Ref
Return the read concern for this client.

return: ReadConcern

getReadPreference()   X-Ref
Return the read preference for this client.

return: ReadPreference

getTypeMap()   X-Ref
Return the type map for this client.

return: array

getWriteConcern()   X-Ref
Return the write concern for this client.

return: WriteConcern

listDatabaseNames(array $options = [])   X-Ref
List database names.


listDatabases(array $options = [])   X-Ref
List databases.

return: DatabaseInfoIterator

selectCollection(string $databaseName, string $collectionName, array $options = [])   X-Ref
Select a collection.

param: string $databaseName   Name of the database containing the collection
param: string $collectionName Name of the collection to select
param: array  $options        Collection constructor options
return: Collection

selectDatabase(string $databaseName, array $options = [])   X-Ref
Select a database.

param: string $databaseName Name of the database to select
param: array  $options      Database constructor options
return: Database

startSession(array $options = [])   X-Ref
Start a new client session.

param: array $options Session options
return: Session

watch(array $pipeline = [], array $options = [])   X-Ref
Create a change stream for watching changes to the cluster.

param: array $pipeline List of pipeline operations
param: array $options  Command options
return: ChangeStream

getVersion()   X-Ref
No description

mergeDriverInfo(array $driver)   X-Ref
No description