Class yii\mongodb\file\Query

Inheritanceyii\mongodb\file\Query » yii\mongodb\Query » yii\base\Component
Implementsyii\db\QueryInterface
Uses Traitsyii\db\QueryTrait
Subclassesyii\mongodb\file\ActiveQuery
Available since version2.0

Query represents Mongo "find" operation for GridFS collection.

Query behaves exactly as regular yii\mongodb\Query. Found files will be represented as arrays of file document attributes with additional 'file' key, which stores \MongoGridFSFile instance.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$from string|array The collection to be selected from. yii\mongodb\Query
$options array Cursor options in format: optionKey => optionValue yii\mongodb\Query
$select array The fields of the results to return. yii\mongodb\Query

Public Methods

Hide inherited methods

MethodDescriptionDefined By
addOptions() Adds additional cursor options. yii\mongodb\Query
all() Executes the query and returns all results as an array. yii\mongodb\Query
andFilterCompare() Helper method for easy querying on values containing some common operators. yii\mongodb\Query
average() Returns the average of the specified column values. yii\mongodb\Query
batch() Starts a batch query. yii\mongodb\Query
buildCursor() Builds the MongoDB cursor for this query. yii\mongodb\Query
column() Executes the query and returns the first column of the result. yii\mongodb\Query
count() Returns the number of records. yii\mongodb\Query
distinct() Returns a list of distinct values for the given column across a collection. yii\mongodb\Query
each() Starts a batch query and retrieves data row by row. yii\mongodb\Query
exists() Returns a value indicating whether the query result contains any row of data. yii\mongodb\Query
from() Sets the collection to be selected from. yii\mongodb\Query
getCollection() Returns the Mongo collection for this query. yii\mongodb\file\Query
max() Returns the maximum of the specified column values. yii\mongodb\Query
min() Returns the minimum of the specified column values. yii\mongodb\Query
modify() Performs 'findAndModify' query and returns a single row of result. yii\mongodb\Query
one() Executes the query and returns a single row of result. yii\mongodb\Query
options() Sets the cursor options. yii\mongodb\Query
populate() Converts the raw query results into the format as specified by this query. yii\mongodb\Query
prepare() Prepares for query building. yii\mongodb\Query
scalar() Returns the query result as a scalar value. yii\mongodb\Query
select() Sets the list of fields of the results to return. yii\mongodb\Query
sum() Returns the sum of the specified column values. yii\mongodb\Query

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
aggregate() Performs the aggregation for the given column. yii\mongodb\Query
fetchRows() Fetches rows from the given Mongo cursor. yii\mongodb\Query
fetchRowsInternal() yii\mongodb\Query

Method Details

getCollection() public method

Returns the Mongo collection for this query.

public yii\mongodb\file\Collection getCollection ( $db null )
$db yii\mongodb\Connection

Mongo connection.

return yii\mongodb\file\Collection

Collection instance.