|
Moodle PHP Documentation 4.1
Moodle 4.1.19+ (Build: 20250711) (5f47dc23ffc)
|
Public Member Functions | |
| __construct (Manager $manager, string $databaseName, array $options=[]) | |
| Constructs new Database instance. | |
| __debugInfo () | |
| Return internal properties for debugging purposes. | |
| __get (string $collectionName) | |
| Select a collection within this database. | |
| __toString () | |
| Return the database name. | |
| aggregate (array $pipeline, array $options=[]) | |
| Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions. | |
| command ($command, array $options=[]) | |
| Execute a command on this database. | |
| createCollection (string $collectionName, array $options=[]) | |
| Create a new collection explicitly. | |
| drop (array $options=[]) | |
| Drop this database. | |
| dropCollection (string $collectionName, array $options=[]) | |
| Drop a collection within this database. | |
| getDatabaseName () | |
| Returns the database name. | |
| getManager () | |
| Return the Manager. | |
| getReadConcern () | |
| Return the read concern for this database. | |
| getReadPreference () | |
| Return the read preference for this database. | |
| getTypeMap () | |
| Return the type map for this database. | |
| getWriteConcern () | |
| Return the write concern for this database. | |
| listCollectionNames (array $options=[]) | |
| Returns the names of all collections in this database. | |
| listCollections (array $options=[]) | |
| Returns information for all collections in this database. | |
| modifyCollection (string $collectionName, array $collectionOptions, array $options=[]) | |
| Modifies a collection or view. | |
| renameCollection (string $fromCollectionName, string $toCollectionName, ?string $toDatabaseName=null, array $options=[]) | |
| Rename a collection within this database. | |
| selectCollection (string $collectionName, array $options=[]) | |
| Select a collection within this database. | |
| selectGridFSBucket (array $options=[]) | |
| Select a GridFS bucket within this database. | |
| watch (array $pipeline=[], array $options=[]) | |
| Create a change stream for watching changes to the database. | |
| withOptions (array $options=[]) | |
| Get a clone of this database with different options. | |
| MongoDB\Database::__construct | ( | Manager | $manager, |
| string | $databaseName, | ||
| array | $options = [] ) |
Constructs new Database instance.
This class provides methods for database-specific operations and serves as a gateway for accessing collections.
Supported options:
| Manager | $manager | Manager instance from the driver |
| string | $databaseName | Database name |
| array | $options | Database options |
| InvalidArgumentException | for parameter/option parsing errors |
| MongoDB\Database::__debugInfo | ( | ) |
Return internal properties for debugging purposes.
| array |
| MongoDB\Database::__get | ( | string | $collectionName | ) |
Select a collection within this database.
Note: collections whose names contain special characters (e.g. ".") may be selected with complex syntax (e.g. $database->{"system.profile"}) or selectCollection().
| string | $collectionName | Name of the collection to select |
| Collection |
| MongoDB\Database::__toString | ( | ) |
Return the database name.
| string |
| MongoDB\Database::aggregate | ( | array | $pipeline, |
| array | $options = [] ) |
Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.
Requires MongoDB >= 3.6
| array | $pipeline | List of pipeline operations |
| array | $options | Command options |
| Traversable |
| UnexpectedValueException | if the command response was malformed |
| UnsupportedException | if options are not supported by the selected server |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::command | ( | $command, | |
| array | $options = [] ) |
Execute a command on this database.
| array | object | $command | Command document |
| array | $options | Options for command execution |
| Cursor |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::createCollection | ( | string | $collectionName, |
| array | $options = [] ) |
Create a new collection explicitly.
| array|object | Command result document |
| UnsupportedException | if options are not supported by the selected server |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::drop | ( | array | $options = [] | ) |
Drop this database.
| array | $options | Additional options |
| array|object | Command result document |
| UnsupportedException | if options are unsupported on the selected server |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::dropCollection | ( | string | $collectionName, |
| array | $options = [] ) |
Drop a collection within this database.
| string | $collectionName | Collection name |
| array | $options | Additional options |
| array|object | Command result document |
| UnsupportedException | if options are unsupported on the selected server |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::getDatabaseName | ( | ) |
Returns the database name.
| string |
| MongoDB\Database::getManager | ( | ) |
Return the Manager.
| Manager |
| MongoDB\Database::getReadConcern | ( | ) |
Return the read concern for this database.
| ReadConcern |
| MongoDB\Database::getReadPreference | ( | ) |
Return the read preference for this database.
| ReadPreference |
| MongoDB\Database::getTypeMap | ( | ) |
Return the type map for this database.
| array |
| MongoDB\Database::getWriteConcern | ( | ) |
Return the write concern for this database.
| WriteConcern |
| MongoDB\Database::listCollectionNames | ( | array | $options = [] | ) |
Returns the names of all collections in this database.
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::listCollections | ( | array | $options = [] | ) |
Returns information for all collections in this database.
| CollectionInfoIterator |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::modifyCollection | ( | string | $collectionName, |
| array | $collectionOptions, | ||
| array | $options = [] ) |
Modifies a collection or view.
| string | $collectionName | Collection or view to modify |
| array | $collectionOptions | Collection or view options to assign |
| array | $options | Command options |
| array|object |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::renameCollection | ( | string | $fromCollectionName, |
| string | $toCollectionName, | ||
| ?string | $toDatabaseName = null, | ||
| array | $options = [] ) |
Rename a collection within this database.
| string | $fromCollectionName | Collection name |
| string | $toCollectionName | New name of the collection |
| string | null | $toDatabaseName | New database name of the collection. Defaults to the original database. |
| array | $options | Additional options |
| array|object | Command result document |
| UnsupportedException | if options are unsupported on the selected server |
| InvalidArgumentException | for parameter/option parsing errors |
| DriverRuntimeException | for other driver errors (e.g. connection errors) |
| MongoDB\Database::selectCollection | ( | string | $collectionName, |
| array | $options = [] ) |
Select a collection within this database.
| string | $collectionName | Name of the collection to select |
| array | $options | Collection constructor options |
| Collection |
| InvalidArgumentException | for parameter/option parsing errors |
| MongoDB\Database::selectGridFSBucket | ( | array | $options = [] | ) |
Select a GridFS bucket within this database.
| array | $options | Bucket constructor options |
| Bucket |
| InvalidArgumentException | for parameter/option parsing errors |
| MongoDB\Database::watch | ( | array | $pipeline = [], |
| array | $options = [] ) |
Create a change stream for watching changes to the database.
| array | $pipeline | List of pipeline operations |
| array | $options | Command options |
| ChangeStream |
| InvalidArgumentException | for parameter/option parsing errors |
| MongoDB\Database::withOptions | ( | array | $options = [] | ) |
Get a clone of this database with different options.
| array | $options | Database constructor options |
| Database |
| InvalidArgumentException | for parameter/option parsing errors |