PHP Class yii\mongodb\file\Collection

A file collection object is usually created by calling [[Database::getFileCollection()]] or [[Connection::getFileCollection()]]. File collection inherits all interface from regular [[\yii\mongo\Collection]], adding methods to store files.
Since: 2.0
Author: Paul Klimov ([email protected])
Inheritance: extends yii\mongodb\Collection
Afficher le fichier Open project: yiisoft/yii2-mongodb Class Usage Examples

Méthodes publiques

Свойство Type Description
$database MongoDB database instance.

Méthodes publiques

Méthode Description
createDownload ( array | MongoDB\BSON\ObjectID $document ) : Download Creates download command.
createUpload ( array $options = [] ) : Upload Creates upload command.
delete ( mixed $id ) : boolean Deletes the file with given _id.
drop ( )
ensureIndexes ( boolean $force = false ) Makes sure that indexes, which are crucial for the file processing, exist at this collection and [[chunkCollection]].
find ( $condition = [], $fields = [], $options = [] ) : Cursor
get ( mixed $id ) : Download | null Retrieves the file with given _id.
getChunkCollection ( boolean $refresh = false ) : Collection Returns the MongoDB collection for the file chunks.
getFileCollection ( boolean $refresh = false ) : Collection Returns the MongoDB collection for the files.
getPrefix ( ) : string
insertFile ( string $filename, array $metadata = [], array $options = [] ) : mixed Creates new file in GridFS collection from given local filesystem file.
insertFileContent ( string $bytes, array $metadata = [], array $options = [] ) : mixed Creates new file in GridFS collection with specified content.
insertUploads ( string $name, array $metadata = [], array $options = [] ) : mixed Creates new file in GridFS collection from uploaded file.
remove ( $condition = [], $options = [] )
setPrefix ( string $prefix )

Private Methods

Méthode Description
ensureChunkIndexes ( ) Ensures indexes at chunk collection.
ensureFileIndexes ( ) Ensures indexes at file collection.

Method Details

createDownload() public méthode

Creates download command.
Since: 2.1
public createDownload ( array | MongoDB\BSON\ObjectID $document ) : Download
$document array | MongoDB\BSON\ObjectID file document ot be downloaded.
Résultat Download file download instance.

createUpload() public méthode

Creates upload command.
Since: 2.1
public createUpload ( array $options = [] ) : Upload
$options array upload options.
Résultat Upload file upload instance.

delete() public méthode

Deletes the file with given _id.
public delete ( mixed $id ) : boolean
$id mixed _id of the file to find.
Résultat boolean whether the operation was successful.

drop() public méthode

public drop ( )

ensureIndexes() public méthode

The check result is cached per collection instance.
public ensureIndexes ( boolean $force = false )
$force boolean whether to ignore internal collection instance cache.

find() public méthode

public find ( $condition = [], $fields = [], $options = [] ) : Cursor
Résultat Cursor cursor for the search results

get() public méthode

Retrieves the file with given _id.
public get ( mixed $id ) : Download | null
$id mixed _id of the file to find.
Résultat Download | null found file, or null if file does not exist

getChunkCollection() public méthode

Returns the MongoDB collection for the file chunks.
public getChunkCollection ( boolean $refresh = false ) : Collection
$refresh boolean whether to reload the collection instance even if it is found in the cache.
Résultat yii\mongodb\Collection mongo collection instance.

getFileCollection() public méthode

Returns the MongoDB collection for the files.
Since: 2.1
public getFileCollection ( boolean $refresh = false ) : Collection
$refresh boolean whether to reload the collection instance even if it is found in the cache.
Résultat yii\mongodb\Collection mongo collection instance.

getPrefix() public méthode

public getPrefix ( ) : string
Résultat string prefix of this file collection.

insertFile() public méthode

Additional attributes can be added file document using $metadata.
public insertFile ( string $filename, array $metadata = [], array $options = [] ) : mixed
$filename string name of the file to store.
$metadata array other metadata fields to include in the file document.
$options array list of options in format: optionName => optionValue
Résultat mixed the "_id" of the saved file document. This will be a generated [[\MongoId]] unless an "_id" was explicitly specified in the metadata.

insertFileContent() public méthode

Additional attributes can be added file document using $metadata.
public insertFileContent ( string $bytes, array $metadata = [], array $options = [] ) : mixed
$bytes string string of bytes to store.
$metadata array other metadata fields to include in the file document.
$options array list of options in format: optionName => optionValue
Résultat mixed the "_id" of the saved file document. This will be a generated [[\MongoId]] unless an "_id" was explicitly specified in the metadata.

insertUploads() public méthode

Additional attributes can be added file document using $metadata.
public insertUploads ( string $name, array $metadata = [], array $options = [] ) : mixed
$name string name of the uploaded file to store. This should correspond to the file field's name attribute in the HTML form.
$metadata array other metadata fields to include in the file document.
$options array list of options in format: optionName => optionValue
Résultat mixed the "_id" of the saved file document. This will be a generated [[\MongoId]] unless an "_id" was explicitly specified in the metadata.

remove() public méthode

public remove ( $condition = [], $options = [] )

setPrefix() public méthode

public setPrefix ( string $prefix )
$prefix string prefix of this file collection.

Property Details

$database public_oe property

MongoDB database instance.
public $database