PHP Class Sokil\Mongo\GridFS

Inheritance: extends Collection
Show file Open project: sokil/php-mongo Class Usage Examples

Protected Properties

Property Type Description
$mongoCollectionClassName

Public Methods

Method Description
deleteFileById ( string | MongoId $id ) : GridFS Delete file by id
getFileById ( MongoId | string | integer $id ) : GridFSFile | null Get file instance by id of document Used \MongoGridFS::findOne() instead of \MongoGridFS::get() due to backward compatibility with old mongo extensions
getFileClassName ( MongoGridFSFile $fileData = null ) : string Override to define class name of file by file data
hydrate ( MongoGridFSFile $data, $useDocumentPool = true ) : Sokil\Mongo\GridFsFile Factory method to get document object from array of stored document
storeBytes ( string $bytes, array $metadata = [] ) : MongoId Create file in GridFS from binary data
storeFile ( string $filename, array $metadata = [] ) : MongoId Create file in GridFS from file in filesystem

Method Details

deleteFileById() public method

Delete file by id
public deleteFileById ( string | MongoId $id ) : GridFS
$id string | MongoId id of file's document
return GridFS

getFileById() public method

Get file instance by id of document Used \MongoGridFS::findOne() instead of \MongoGridFS::get() due to backward compatibility with old mongo extensions
public getFileById ( MongoId | string | integer $id ) : GridFSFile | null
$id MongoId | string | integer
return GridFSFile | null

getFileClassName() public method

Override to define class name of file by file data
public getFileClassName ( MongoGridFSFile $fileData = null ) : string
$fileData MongoGridFSFile
return string Document class data

hydrate() public method

Factory method to get document object from array of stored document
public hydrate ( MongoGridFSFile $data, $useDocumentPool = true ) : Sokil\Mongo\GridFsFile
$data MongoGridFSFile
return Sokil\Mongo\GridFsFile

storeBytes() public method

Create file in GridFS from binary data
public storeBytes ( string $bytes, array $metadata = [] ) : MongoId
$bytes string binary data to store in GridFS
$metadata array metadata stored with file
return MongoId Id of stored file

storeFile() public method

Create file in GridFS from file in filesystem
public storeFile ( string $filename, array $metadata = [] ) : MongoId
$filename string name of source file
$metadata array metadata stored with file
return MongoId Id of stored file

Property Details

$mongoCollectionClassName protected property

protected $mongoCollectionClassName