MongoGridFS
class MongoGridFS extends MongoCollection (View source)
Constants
ASCENDING |
|
DESCENDING |
|
Properties
MongoDB | $db | from MongoCollection | |
int | $w | from MongoCollection | |
int | $wtimeout | from MongoCollection | |
MongoCollection | $chunks | ||
protected string | $filesName | ||
protected string | $chunksName |
Methods
Files as stored across two collections, the first containing file meta information, the second containing chunks of the actual file. By default, fs.files and fs.chunks are the collection names used.
(PECL mongo >= 1.3.0)
The MongoDB https://docs.mongodb.org/manual/applications/aggregation/ aggregation framework provides a means to calculate aggregated values without having to use MapReduce. While MapReduce is powerful, it is often more difficult than necessary for many simple aggregation tasks, such as totaling or averaging field values.
(PECL mongo >= 1.5.0)
(PECL mongo >= 1.1.0)
See https://secure.php.net/manual/en/mongo.queries.php the query section of this manual for information on distributing reads to secondaries.
(PECL mongo >= 1.1.0)
See https://secure.php.net/manual/en/mongo.queries.php the query section of this manual for information on distributing reads to secondaries.
(PECL mongo >= 1.3.0)
Drops the files and chunks collections
Inserts an array into the collection
Inserts multiple documents into this collection
Update records based on a given criteria
Removes files from the collections
No description
Retrieve a list of distinct values for the given key across a collection
Update a document and return it
Returns a single file matching the criteria
Creates an index on the given field(s), or does nothing if the index already exists
Creates an index on the given field(s), or does nothing if the index already exists
Saves an object to this collection
Fetches the document pointed to by a database reference
Performs an operation similar to SQL's GROUP BY command
Stores a file in the database
Chunkifies and stores bytes in the database
Delete a file from the database
Saves an uploaded file directly from a POST to the database
Retrieve a file from the database
Stores a file in the database
Details
__construct(MongoDB $db, string $prefix = "fs", mixed $chunks = "fs")
Files as stored across two collections, the first containing file meta information, the second containing chunks of the actual file. By default, fs.files and fs.chunks are the collection names used.
string
__toString()
String representation of this collection
MongoCollection
__get(string $name)
Gets a collection
array
aggregate(array $pipeline, array $op, array $pipelineOperators)
(PECL mongo >= 1.3.0)
The MongoDB https://docs.mongodb.org/manual/applications/aggregation/ aggregation framework provides a means to calculate aggregated values without having to use MapReduce. While MapReduce is powerful, it is often more difficult than necessary for many simple aggregation tasks, such as totaling or averaging field values.
This method accepts either a variable amount of pipeline operators, or a single array of operators constituting the pipeline.
MongoCommandCursor
aggregateCursor(array $pipeline, array $options)
(PECL mongo >= 1.5.0)
With this method you can execute Aggregation Framework pipelines and retrieve the results through a cursor, instead of getting just one document back as you would with https://php.net/manual/en/mongocollection.aggregate.php MongoCollection::aggregate(). This method returns a https://php.net/manual/en/class.mongocommandcursor.php MongoCommandCursor object. This cursor object implements the https://php.net/manual/en/class.iterator.php Iterator interface just like the https://php.net/manual/en/class.mongocursor.php MongoCursor objects that are returned by the https://php.net/manual/en/mongocollection.find.php MongoCollection::find() method
string
getName()
Returns this collection's name
bool
getSlaveOkay()
(PECL mongo >= 1.1.0)
See https://secure.php.net/manual/en/mongo.queries.php the query section of this manual for information on distributing reads to secondaries.
bool
setSlaveOkay(bool $ok = true)
(PECL mongo >= 1.1.0)
See https://secure.php.net/manual/en/mongo.queries.php the query section of this manual for information on distributing reads to secondaries.
array
getReadPreference()
(PECL mongo >= 1.3.0)
bool
setReadPreference(string $read_preference, array $tags)
(PECL mongo >= 1.3.0)
array
drop()
Drops the files and chunks collections
array
validate(bool $scan_data = false)
Validates this collection
bool|array
insert(array|object $a, array $options = [])
Inserts an array into the collection
array|bool
batchInsert(array $a, array $options = [])
Inserts multiple documents into this collection
bool
update(array $criteria, array $newobj, array $options = [])
Update records based on a given criteria
bool|array
remove(array $criteria = [], array $options = [])
Removes files from the collections
MongoCursor
find(array $query = [], array $fields = [])
No description
array|false
distinct(string $key, array $query = null)
Retrieve a list of distinct values for the given key across a collection
array
findAndModify(array $query, array $update = null, array $fields = null, array $options = null)
Update a document and return it
array|null
findOne(array $query = [], array $fields = [])
Returns a single file matching the criteria
array
createIndex(array $keys, array $options = [])
Creates an index on the given field(s), or does nothing if the index already exists
true
ensureIndex(array $keys, array $options = [])
Creates an index on the given field(s), or does nothing if the index already exists
array
deleteIndex(string|array $keys)
Deletes an index from this collection
array
deleteIndexes()
Delete all indexes for this collection
array
getIndexInfo()
Returns an array of index names for this collection
int
count(array|stdClass $query = [])
Counts the number of documents in this collection
array|bool
save(array|object $a, array $options = [])
Saves an object to this collection
array
createDBRef(array $a)
Creates a database reference
array
getDBRef(array $ref)
Fetches the document pointed to by a database reference
static protected string
toIndexString(mixed $keys)
No description
array
group(mixed $keys, array $initial, MongoCode $reduce, array $condition = [])
Performs an operation similar to SQL's GROUP BY command
mixed
storeFile(string|resource $filename, array $extra = [], array $options = [])
Stores a file in the database
mixed
storeBytes(string $bytes, array $extra = [], array $options = [])
Chunkifies and stores bytes in the database
bool
delete(mixed $id)
Delete a file from the database
mixed
storeUpload(string $name, array $metadata = [])
Saves an uploaded file directly from a POST to the database
MongoGridFSFile|null
get(mixed $id)
Retrieve a file from the database
mixed
put(string $filename, array $extra = [])
Stores a file in the database