PHP Class yii\mongodb\Database

Since: 2.0
Author: Paul Klimov ([email protected])
Inheritance: extends yii\base\Object
Afficher le fichier Open project: yiisoft/yii2-mongodb

Méthodes publiques

Свойство Type Description
$connection MongoDB connection.
$name name of this database.

Méthodes publiques

Méthode Description
clearCollections ( ) Clears internal collection lists.
createCollection ( string $name, array $options = [] ) : boolean Creates new collection.
createCommand ( array $document = [] ) : Command Creates MongoDB command associated with this database.
dropCollection ( string $name ) : boolean Drops specified collection.
getCollection ( string $name, boolean $refresh = false ) : Collection Returns the Mongo collection with the given name.
getFileCollection ( string $prefix = 'fs', boolean $refresh = false ) : Collection Returns Mongo GridFS collection with given prefix.
listCollections ( array $condition = [], array $options = [] ) : array Returns the list of available collections in this database.

Méthodes protégées

Méthode Description
selectCollection ( string $name ) : Collection Selects collection with given name.
selectFileCollection ( string $prefix ) : Collection Selects GridFS collection with given prefix.

Method Details

clearCollections() public méthode

This method can be used to break cycle references between Database and Collection instances.
public clearCollections ( )

createCollection() public méthode

Note: Mongo creates new collections automatically on the first demand, this method makes sense only for the migration script or for the case you need to create collection with the specific options.
public createCollection ( string $name, array $options = [] ) : boolean
$name string name of the collection
$options array collection options in format: "name" => "value"
Résultat boolean whether operation was successful.

createCommand() public méthode

Creates MongoDB command associated with this database.
Since: 2.1
public createCommand ( array $document = [] ) : Command
$document array command document contents.
Résultat Command command instance.

dropCollection() public méthode

Drops specified collection.
Since: 2.1
public dropCollection ( string $name ) : boolean
$name string name of the collection
Résultat boolean whether operation was successful.

getCollection() public méthode

Returns the Mongo collection with the given name.
public getCollection ( string $name, boolean $refresh = false ) : Collection
$name string collection name
$refresh boolean whether to reload the collection instance even if it is found in the cache.
Résultat Collection Mongo collection instance.

getFileCollection() public méthode

Returns Mongo GridFS collection with given prefix.
public getFileCollection ( string $prefix = 'fs', boolean $refresh = false ) : Collection
$prefix string collection prefix.
$refresh boolean whether to reload the collection instance even if it is found in the cache.
Résultat yii\mongodb\file\Collection Mongo GridFS collection.

listCollections() public méthode

Returns the list of available collections in this database.
Since: 2.1.1
public listCollections ( array $condition = [], array $options = [] ) : array
$condition array filter condition.
$options array options list.
Résultat array collections information.

selectCollection() protected méthode

Selects collection with given name.
protected selectCollection ( string $name ) : Collection
$name string collection name.
Résultat Collection collection instance.

selectFileCollection() protected méthode

Selects GridFS collection with given prefix.
protected selectFileCollection ( string $prefix ) : Collection
$prefix string file collection prefix.
Résultat yii\mongodb\file\Collection file collection instance.

Property Details

$connection public_oe property

MongoDB connection.
public $connection

$name public_oe property

name of this database.
public $name