Свойство | Тип | Описание | |
---|---|---|---|
$from | the collection to be selected from. If string considered as the name of the collection inside the default database. If array - first element considered as the name of the database, second - as name of collection inside that database | ||
$options | cursor options in format: optionKey => optionValue | ||
$select | the fields of the results to return. For example: ['name', 'group_id'], ['name' => true, '_id' => false]. Unless directly excluded, the "_id" field is always returned. If not set, it means selecting all columns. |
Метод | Описание | |
---|---|---|
addOptions ( array $options ) | Adds additional cursor options. | |
all ( |
Executes the query and returns all results as an array. | |
andFilterCompare ( string $name, string $value, string $defaultOperator = '=' ) | Helper method for easy querying on values containing some common operators. | |
average ( string $q, |
Returns the average of the specified column values. | |
batch ( integer $batchSize = 100, |
Starts a batch query. | |
buildCursor ( |
Builds the Mongo cursor for this query. | |
column ( |
Executes the query and returns the first column of the result. | |
count ( string $q = '*', |
Returns the number of records. | |
distinct ( string $q, |
Returns a list of distinct values for the given column across a collection. | |
each ( integer $batchSize = 100, |
Starts a batch query and retrieves data row by row. | |
exists ( |
Returns a value indicating whether the query result contains any row of data. | |
from ( $collection ) | Sets the collection to be selected from. | |
getCollection ( |
Returns the Mongo collection for this query. | |
max ( string $q, |
Returns the maximum of the specified column values. | |
min ( string $q, |
Returns the minimum of the specified column values. | |
modify ( array $update, array $options = [], |
Performs 'findAndModify' query and returns a single row of result. | |
one ( |
Executes the query and returns a single row of result. | |
options ( array $options ) | Sets the cursor options. | |
populate ( array $rows ) : array | Converts the raw query results into the format as specified by this query. | |
scalar ( |
Returns the query result as a scalar value. | |
select ( array $fields ) | Sets the list of fields of the results to return. | |
sum ( string $q, |
Returns the sum of the specified column values. |
Метод | Описание | |
---|---|---|
aggregate ( string $column, string $operator, |
Performs the aggregation for the given column. | |
fetchRows ( MongoDB\Driver\Cursor $cursor, boolean $all = true, string | callable $indexBy = null ) : array | boolean | Fetches rows from the given Mongo cursor. | |
fetchRowsInternal ( MongoDB\Driver\Cursor $cursor, boolean $all ) : array | boolean |
Метод | Описание | |
---|---|---|
composeCondition ( ) : array | Composes condition from raw [[where]] value. |
public addOptions ( array $options ) | ||
$options | array | cursor options in format: optionName => optionValue |
public average ( string $q, |
||
$q | string | the column name. Make sure you properly quote column names in the expression. |
$db | the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. | |
Результат | integer | the average of the specified column values. |
public batch ( integer $batchSize = 100, |
||
$batchSize | integer | the number of records to be fetched in each batch. |
$db | the MongoDB connection. If not set, the "mongodb" application component will be used. | |
Результат | the batch query result. It implements the `Iterator` interface and can be traversed to retrieve the data in batches. |
public buildCursor ( |
||
$db | the database connection used to execute the query. | |
Результат | MongoDB\Driver\Cursor | mongo cursor instance. |
public column ( |
||
$db | the MongoDB connection used to generate the query. If this parameter is not given, the `mongodb` application component will be used. | |
Результат | array | the first column of the query result. An empty array is returned if the query results in nothing. |
public count ( string $q = '*', |
||
$q | string | kept to match [[QueryInterface]], its value is ignored. |
$db | the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. | |
Результат | integer | number of records |
public each ( integer $batchSize = 100, |
||
$batchSize | integer | the number of records to be fetched in each batch. |
$db | the MongoDB connection. If not set, the "mongodb" application component will be used. | |
Результат | the batch query result. It implements the `Iterator` interface and can be traversed to retrieve the data in batches. |
protected fetchRows ( MongoDB\Driver\Cursor $cursor, boolean $all = true, string | callable $indexBy = null ) : array | boolean | ||
$cursor | MongoDB\Driver\Cursor | Mongo cursor instance to fetch data from. |
$all | boolean | whether to fetch all rows or only first one. |
$indexBy | string | callable | the column name or PHP callback, by which the query results should be indexed by. |
Результат | array | boolean | result. |
public getCollection ( |
||
$db | Mongo connection. | |
Результат | collection instance. |
public max ( string $q, |
||
$q | string | the column name. Make sure you properly quote column names in the expression. |
$db | the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. | |
Результат | integer | the maximum of the specified column values. |
public min ( string $q, |
||
$q | string | the column name. Make sure you properly quote column names in the expression. |
$db | the database connection used to generate the SQL statement. If this parameter is not given, the `db` application component will be used. | |
Результат | integer | the minimum of the specified column values. |
public modify ( array $update, array $options = [], |
||
$update | array | update criteria |
$options | array | list of options in format: optionName => optionValue. |
$db | the Mongo connection used to execute the query. | |
Результат | array | null | the original document, or the modified document when $options['new'] is set. |
public one ( |
||
$db | the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. | |
Результат | array | boolean | the first row (in terms of an array) of the query result. False is returned if the query results in nothing. |
public scalar ( |
||
$db | the MongoDB connection used to generate the query. If this parameter is not given, the `mongodb` application component will be used. | |
Результат | string | null | false | the value of the first column in the first row of the query result. `false` is returned if the query result is empty. |
public sum ( string $q, |
||
$q | string | the column name. Make sure you properly quote column names in the expression. |
$db | the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used. | |
Результат | integer | the sum of the specified column values |
public $from |