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
파일 보기 프로젝트 열기: yiisoft/yii2-mongodb 1 사용 예제들

공개 메소드들

메소드 설명
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.