Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

(no description)

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

Defines 1 class

Client:: (15 methods):
  __construct()
  __debugInfo()
  __get()
  __toString()
  dropDatabase()
  getManager()
  getReadConcern()
  getReadPreference()
  getTypeMap()
  getWriteConcern()
  listDatabases()
  selectCollection()
  selectDatabase()
  startSession()
  watch()


Class: Client  - X-Ref

__construct($uri = 'mongodb:)   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 $uri           MongoDB connection string
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($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

dropDatabase($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

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

param: array $options
return: DatabaseInfoIterator

selectCollection($databaseName, $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($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