PHP Класс 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.
С версии: 2.0
Автор: Paul Klimov ([email protected])
Наследование: extends yii\mongodb\Collection
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$database MongoDB database instance.

Открытые методы

Метод Описание
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 )

Приватные методы

Метод Описание
ensureChunkIndexes ( ) Ensures indexes at chunk collection.
ensureFileIndexes ( ) Ensures indexes at file collection.

Описание методов

createDownload() публичный Метод

Creates download command.
С версии: 2.1
public createDownload ( array | MongoDB\BSON\ObjectID $document ) : Download
$document array | MongoDB\BSON\ObjectID file document ot be downloaded.
Результат Download file download instance.

createUpload() публичный Метод

Creates upload command.
С версии: 2.1
public createUpload ( array $options = [] ) : Upload
$options array upload options.
Результат Upload file upload instance.

delete() публичный Метод

Deletes the file with given _id.
public delete ( mixed $id ) : boolean
$id mixed _id of the file to find.
Результат boolean whether the operation was successful.

drop() публичный Метод

public drop ( )

ensureIndexes() публичный Метод

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

find() публичный Метод

public find ( $condition = [], $fields = [], $options = [] ) : Cursor
Результат Cursor cursor for the search results

get() публичный Метод

Retrieves the file with given _id.
public get ( mixed $id ) : Download | null
$id mixed _id of the file to find.
Результат Download | null found file, or null if file does not exist

getChunkCollection() публичный Метод

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.
Результат yii\mongodb\Collection mongo collection instance.

getFileCollection() публичный Метод

Returns the MongoDB collection for the files.
С версии: 2.1
public getFileCollection ( boolean $refresh = false ) : Collection
$refresh boolean whether to reload the collection instance even if it is found in the cache.
Результат yii\mongodb\Collection mongo collection instance.

getPrefix() публичный Метод

public getPrefix ( ) : string
Результат string prefix of this file collection.

insertFile() публичный Метод

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
Результат mixed the "_id" of the saved file document. This will be a generated [[\MongoId]] unless an "_id" was explicitly specified in the metadata.

insertFileContent() публичный Метод

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
Результат mixed the "_id" of the saved file document. This will be a generated [[\MongoId]] unless an "_id" was explicitly specified in the metadata.

insertUploads() публичный Метод

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
Результат 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 remove ( $condition = [], $options = [] )

setPrefix() публичный Метод

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

Описание свойств

$database публичное свойство

MongoDB database instance.
public $database