PHP Класс yii\mongodb\file\ActiveRecord

To specify source file use the [[file]] attribute. It can be specified in one of the following ways: - string - full name of the file, which content should be stored in GridFS - \yii\web\UploadedFile - uploaded file instance, which content should be stored in GridFS For example: php $record = new ImageFile(); $record->file = '/path/to/some/file.jpg'; $record->save(); You can also specify file content via [[newFileContent]] attribute: php $record = new ImageFile(); $record->newFileContent = 'New file content'; $record->save(); Note: [[newFileContent]] always takes precedence over [[file]].
С версии: 2.0
Автор: Paul Klimov ([email protected])
Наследование: extends yii\mongodb\ActiveRecord
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
attributes ( ) : array Returns the list of all attribute names of the model.
find ( ) : yii\mongodb\file\ActiveQuery
getCollection ( ) : Collection Return the Mongo GridFS collection instance for this AR class.
getFileContent ( ) : null | string Returns the associated file content.
getFileResource ( ) : resource This method returns a stream resource that can be used with all file functions in PHP, which deal with reading files. The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first.
refreshFile ( ) : MongoGridFSFile | null Refreshes the [[file]] attribute from file collection, using current primary key.
writeFile ( string $filename ) : boolean Writes the the internal file content into the given filename.

Защищенные методы

Метод Описание
extractFileName ( mixed $file ) : string Extracts filename from given raw file value.
insertInternal ( $attributes = null )
updateInternal ( $attributes = null )

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

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

This method could be overridden by child classes to define available attributes. Note: all attributes defined in base Active Record class should be always present in returned array. For example: php public function attributes() { return array_merge( parent::attributes(), ['tags', 'status'] ); }
public attributes ( ) : array
Результат array list of attribute names.

extractFileName() защищенный Метод

Extracts filename from given raw file value.
protected extractFileName ( mixed $file ) : string
$file mixed raw file value.
Результат string file name.

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

public static find ( ) : yii\mongodb\file\ActiveQuery
Результат yii\mongodb\file\ActiveQuery the newly created [[ActiveQuery]] instance.

getCollection() публичный статический Метод

Return the Mongo GridFS collection instance for this AR class.
public static getCollection ( ) : Collection
Результат Collection collection instance.

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

Returns the associated file content.
public getFileContent ( ) : null | string
Результат null | string file content.

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

This method returns a stream resource that can be used with all file functions in PHP, which deal with reading files. The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first.
public getFileResource ( ) : resource
Результат resource file stream resource.

insertInternal() защищенный Метод

См. также: ActiveRecord::insert()
protected insertInternal ( $attributes = null )

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

Refreshes the [[file]] attribute from file collection, using current primary key.
public refreshFile ( ) : MongoGridFSFile | null
Результат MongoGridFSFile | null refreshed file value.

updateInternal() защищенный Метод

См. также: ActiveRecord::update()
protected updateInternal ( $attributes = null )

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

Writes the the internal file content into the given filename.
public writeFile ( string $filename ) : boolean
$filename string full filename to be written.
Результат boolean whether the operation was successful.