PHP Class Phalcon\Db\Adapter\MongoDB\GridFS\CollectionWrapper

Datei anzeigen Open project: phalcon/incubator Class Usage Examples

Public Methods

Method Description
__construct ( MongoDB\Driver\Manager $manager, string $databaseName, string $bucketName, array $collectionOptions = [] ) Constructs a GridFS collection wrapper.
deleteChunksByFilesId ( mixed $id ) Deletes all GridFS chunks for a given file ID.
deleteFileAndChunksById ( mixed $id ) Deletes a GridFS file and related chunks by ID.
dropCollections ( ) Drops the GridFS files and chunks collections.
findFileByFilenameAndRevision ( string $filename, integer $revision ) : stdClas\stdClass | null Finds a GridFS file document for a given filename and revision.
findFileById ( mixed $id ) : stdClas\stdClass | null Finds a GridFS file document for a given ID.
findFiles ( array | object $filter, array $options = [] ) : MongoDB\Driver\Cursor Finds documents from the GridFS bucket's files collection.
getChunksCollection ( ) TODO: Remove this
getChunksIteratorByFilesId ( mixed $id ) : IteratorIterator Returns a chunks iterator for a given file ID.
getFilesCollection ( ) TODO: Remove this
insertChunk ( array | object $chunk ) Inserts a document into the chunks collection.
insertFile ( array | object $file ) Inserts a document into the files collection.
updateFilenameForId ( mixed $id, string $filename ) : UpdateResult Updates the filename field in the file document for a given ID.

Private Methods

Method Description
ensureChunksIndex ( ) Create an index on the chunks collection if it does not already exist.
ensureFilesIndex ( ) Create an index on the files collection if it does not already exist.
ensureIndexes ( ) Ensure indexes on the files and chunks collections exist.
isFilesCollectionEmpty ( ) : boolean Returns whether the files collection is empty.

Method Details

__construct() public method

Constructs a GridFS collection wrapper.
See also: Collection::__construct() for supported options
public __construct ( MongoDB\Driver\Manager $manager, string $databaseName, string $bucketName, array $collectionOptions = [] )
$manager MongoDB\Driver\Manager Manager instance from the driver
$databaseName string Database name
$bucketName string Bucket name
$collectionOptions array Collection options

deleteChunksByFilesId() public method

Deletes all GridFS chunks for a given file ID.
public deleteChunksByFilesId ( mixed $id )
$id mixed

deleteFileAndChunksById() public method

Deletes a GridFS file and related chunks by ID.
public deleteFileAndChunksById ( mixed $id )
$id mixed

dropCollections() public method

Drops the GridFS files and chunks collections.
public dropCollections ( )

findFileByFilenameAndRevision() public method

Revision numbers are defined as follows: * 0 = the original stored file * 1 = the first revision * 2 = the second revision * etc… * -2 = the second most recent revision * -1 = the most recent revision
See also: Bucket::downloadToStreamByName()
See also: Bucket::openDownloadStreamByName()
public findFileByFilenameAndRevision ( string $filename, integer $revision ) : stdClas\stdClass | null
$filename string
$revision integer
return stdClas\stdClass | null

findFileById() public method

Finds a GridFS file document for a given ID.
public findFileById ( mixed $id ) : stdClas\stdClass | null
$id mixed
return stdClas\stdClass | null

findFiles() public method

Finds documents from the GridFS bucket's files collection.
See also: Find::__construct() for supported options
public findFiles ( array | object $filter, array $options = [] ) : MongoDB\Driver\Cursor
$filter array | object Query by which to filter documents
$options array Additional options
return MongoDB\Driver\Cursor

getChunksCollection() public method

TODO: Remove this
public getChunksCollection ( )

getChunksIteratorByFilesId() public method

Returns a chunks iterator for a given file ID.

getFilesCollection() public method

TODO: Remove this
public getFilesCollection ( )

insertChunk() public method

Inserts a document into the chunks collection.
public insertChunk ( array | object $chunk )
$chunk array | object Chunk document

insertFile() public method

The file document should be inserted after all chunks have been inserted.
public insertFile ( array | object $file )
$file array | object File document

updateFilenameForId() public method

Updates the filename field in the file document for a given ID.
public updateFilenameForId ( mixed $id, string $filename ) : UpdateResult
$id mixed
$filename string
return Phalcon\Db\Adapter\MongoDB\UpdateResult