Inheritance | yii\mongodb\Database » yii\base\Object |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-mongodb/blob/master/Database.php |
Database represents the Mongo database information.
Property | Type | Description | Defined By |
---|---|---|---|
$connection | yii\mongodb\Connection | MongoDB connection. | yii\mongodb\Database |
$fileCollection | yii\mongodb\file\Collection | Mongo GridFS collection. | yii\mongodb\Database |
$name | string | Name of this database. | yii\mongodb\Database |
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Object |
__construct() | Constructor. | yii\base\Object |
__get() | Returns the value of an object property. | yii\base\Object |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Object |
__set() | Sets value of an object property. | yii\base\Object |
__unset() | Sets an object property to null. | yii\base\Object |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Object |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Object |
className() | Returns the fully qualified name of this class. | yii\base\Object |
clearCollections() | Clears internal collection lists. | yii\mongodb\Database |
createCollection() | Creates new collection. | yii\mongodb\Database |
createCommand() | Creates MongoDB command associated with this database. | yii\mongodb\Database |
dropCollection() | Drops specified collection. | yii\mongodb\Database |
getCollection() | Returns the Mongo collection with the given name. | yii\mongodb\Database |
getFileCollection() | Returns Mongo GridFS collection with given prefix. | yii\mongodb\Database |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Object |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\Object |
init() | Initializes the object. | yii\base\Object |
listCollections() | Returns the list of available collections in this database. | yii\mongodb\Database |
Method | Description | Defined By |
---|---|---|
selectCollection() | Selects collection with given name. | yii\mongodb\Database |
selectFileCollection() | Selects GridFS collection with given prefix. | yii\mongodb\Database |
MongoDB connection.
public yii\mongodb\Connection $connection = null
Mongo GridFS collection.
public yii\mongodb\file\Collection getFileCollection ( $prefix = 'fs', $refresh = false )
Name of this database.
public string $name = null
Clears internal collection lists.
This method can be used to break cycle references between yii\mongodb\Database and yii\mongodb\Collection instances.
public void clearCollections ( ) |
---|
Creates new collection.
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 boolean createCollection ( $name, $options = [] ) | ||
---|---|---|
$name | string |
Name of the collection |
$options | array |
Collection options in format: "name" => "value" |
return | boolean |
Whether operation was successful. |
throws | yii\mongodb\Exception |
on failure. |
Creates MongoDB command associated with this database.
public yii\mongodb\Command createCommand ( $document = [] ) | ||
---|---|---|
$document | array |
Command document contents. |
return | yii\mongodb\Command |
Command instance. |
Drops specified collection.
public boolean dropCollection ( $name ) | ||
---|---|---|
$name | string |
Name of the collection |
return | boolean |
Whether operation was successful. |
Returns the Mongo collection with the given name.
public yii\mongodb\Collection getCollection ( $name, $refresh = false ) | ||
---|---|---|
$name | string |
Collection name |
$refresh | boolean |
Whether to reload the collection instance even if it is found in the cache. |
return | yii\mongodb\Collection |
Mongo collection instance. |
Returns Mongo GridFS collection with given prefix.
public yii\mongodb\file\Collection getFileCollection ( $prefix = 'fs', $refresh = false ) | ||
---|---|---|
$prefix | string |
Collection prefix. |
$refresh | boolean |
Whether to reload the collection instance even if it is found in the cache. |
return | yii\mongodb\file\Collection |
Mongo GridFS collection. |
Returns the list of available collections in this database.
public array listCollections ( $condition = [], $options = [] ) | ||
---|---|---|
$condition | array |
Filter condition. |
$options | array |
Options list. |
return | array |
Collections information. |
Selects collection with given name.
protected yii\mongodb\Collection selectCollection ( $name ) | ||
---|---|---|
$name | string |
Collection name. |
return | yii\mongodb\Collection |
Collection instance. |
Selects GridFS collection with given prefix.
protected yii\mongodb\file\Collection selectFileCollection ( $prefix ) | ||
---|---|---|
$prefix | string |
File collection prefix. |
return | yii\mongodb\file\Collection |
File collection instance. |
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-mongodb-database.html