class GridFSFile (View source)

Wrapper for the MongoGridFSFile class.

Files may be dirty, which means that they must be persisted to the database. Clean files are assumed to be in sync with the database.

Methods

__construct(string|MongoGridFSFile $file = null)

Constructor.

string|null
getBytes()

Get the bytes for this file.

setBytes(string $bytes)

Set the bytes to be persisted and mark the file as dirty.

string|null
getFilename()

Get the filename for this file.

setFilename(string $filename)

Set the filename to be persisted and mark the file as dirty.

MongoGridFSFile
getMongoGridFSFile()

Get the PHP MongoGridFSFile instance being wrapped.

setMongoGridFSFile(MongoGridFSFile $mongoGridFSFile)

Set the PHP MongoGridFSFile instance to wrap and mark the file as clean.

integer
getSize()

Get the size of this file.

boolean
hasUnpersistedBytes()

Check whether there are unpersisted bytes.

boolean
hasUnpersistedFile()

Check whether there is an unpersisted file.

boolean
isDirty(boolean $isDirty = null)

Check whether the file is dirty.

integer
write(string $filename)

Writes this file to the path indicated by $filename.

Details

__construct(string|MongoGridFSFile $file = null)

Constructor.

If the $file parameter is a MongoGridFSFile instance, this file will not initially be marked as dirty (i.e. in need of persistence).

Parameters

string|MongoGridFSFile $file String filename or a GridFSFile object

string|null getBytes()

Get the bytes for this file.

Return Value

string|null

setBytes(string $bytes)

Set the bytes to be persisted and mark the file as dirty.

Parameters

string $bytes

string|null getFilename()

Get the filename for this file.

Return Value

string|null

setFilename(string $filename)

Set the filename to be persisted and mark the file as dirty.

Parameters

string $filename

MongoGridFSFile getMongoGridFSFile()

Get the PHP MongoGridFSFile instance being wrapped.

Return Value

MongoGridFSFile

setMongoGridFSFile(MongoGridFSFile $mongoGridFSFile)

Set the PHP MongoGridFSFile instance to wrap and mark the file as clean.

Parameters

MongoGridFSFile $mongoGridFSFile

integer getSize()

Get the size of this file.

Return Value

integer

boolean hasUnpersistedBytes()

Check whether there are unpersisted bytes.

Return Value

boolean

boolean hasUnpersistedFile()

Check whether there is an unpersisted file.

Return Value

boolean

boolean isDirty(boolean $isDirty = null)

Check whether the file is dirty.

If $isDirty is not null, the dirty state will be set before its new value is returned.

Parameters

boolean $isDirty

Return Value

boolean

integer write(string $filename)

Writes this file to the path indicated by $filename.

Parameters

string $filename

Return Value

integer Number of bytes written

Exceptions

BadMethodCallException if nothing can be written