Property | Type | Description | |
---|---|---|---|
$emulateExecution | whether to emulate the actual query execution, returning empty or false results. | ||
$indexBy | string | callable | ||
$limit | maximum number of records to be returned. If not set or less than 0, it means no limit. | ||
$offset | zero-based offset from where the records are to be returned. If not set or less than 0, it means starting from the beginning. | ||
$orderBy | how to sort the query results. This is used to construct the ORDER BY clause in a SQL statement. The array keys are the columns to be sorted by, and the array values are the corresponding sort directions which can be either SORT_ASC or SORT_DESC. The array may also contain [[Expression]] objects. If that is the case, the expressions will be converted into strings without any change. | ||
$where | query condition. This refers to the WHERE clause in a SQL statement. For example, ['age' => 31, 'team' => 1]. |
Method | Description | |
---|---|---|
addOrderBy ( string | array | yii\db\Expression $columns ) | Adds additional ORDER BY columns to the query. | |
andFilterWhere ( array $condition ) | Adds an additional WHERE condition to the existing one but ignores [[isEmpty()|empty operands]]. | |
andWhere ( string | array $condition ) | Adds an additional WHERE condition to the existing one. | |
emulateExecution ( boolean $value = true ) | Sets whether to emulate query execution, preventing any interaction with data storage. | |
filterWhere ( array $condition ) | Sets the WHERE part of the query but ignores [[isEmpty()|empty operands]]. | |
indexBy ( string | callable $column ) | Sets the [[indexBy]] property. | |
limit ( integer $limit ) | Sets the LIMIT part of the query. | |
offset ( integer $offset ) | Sets the OFFSET part of the query. | |
orFilterWhere ( array $condition ) | Adds an additional WHERE condition to the existing one but ignores [[isEmpty()|empty operands]]. | |
orWhere ( string | array $condition ) | Adds an additional WHERE condition to the existing one. | |
orderBy ( string | array | yii\db\Expression $columns ) | Sets the ORDER BY part of the query. | |
where ( string | array $condition ) | Sets the WHERE part of the query. |
Method | Description | |
---|---|---|
filterCondition ( array $condition ) : array | Removes [[isEmpty()|empty operands]] from the given query condition. | |
isEmpty ( mixed $value ) : boolean | Returns a value indicating whether the give value is "empty". | |
normalizeOrderBy ( array | string | yii\db\Expression $columns ) : array | Normalizes format of ORDER BY data |
public addOrderBy ( string | array | yii\db\Expression $columns ) | ||
$columns | string | array | yii\db\Expression | the columns (and the directions) to be ordered by. Columns can be specified in either a string (e.g. "id ASC, name DESC") or an array (e.g. `['id' => SORT_ASC, 'name' => SORT_DESC]`). The method will automatically quote the column names unless a column contains some parenthesis (which means the column contains a DB expression). Note that if your order-by is an expression containing commas, you should always use an array to represent the order-by information. Otherwise, the method will not be able to correctly determine the order-by columns. Since version 2.0.7, an [[Expression]] object can be passed to specify the ORDER BY part explicitly in plain SQL. |
public andFilterWhere ( array $condition ) | ||
$condition | array | the new WHERE condition. Please refer to [[where()]] on how to specify this parameter. |
public emulateExecution ( boolean $value = true ) | ||
$value | boolean | whether to prevent query execution. |
protected filterCondition ( array $condition ) : array | ||
$condition | array | the original condition |
return | array | the condition with [[isEmpty()|empty operands]] removed. |
public filterWhere ( array $condition ) | ||
$condition | array | the conditions that should be put in the WHERE part. See [[where()]] on how to specify this parameter. |
public indexBy ( string | callable $column ) | ||
$column | string | callable | the name of the column by which the query results should be indexed by. This can also be a callable (e.g. anonymous function) that returns the index value based on the given row data. The signature of the callable should be: ```php function ($row) { // return the index value corresponding to $row } ``` |
public orFilterWhere ( array $condition ) | ||
$condition | array | the new WHERE condition. Please refer to [[where()]] on how to specify this parameter. |
public orderBy ( string | array | yii\db\Expression $columns ) | ||
$columns | string | array | yii\db\Expression | the columns (and the directions) to be ordered by. Columns can be specified in either a string (e.g. `"id ASC, name DESC"`) or an array (e.g. `['id' => SORT_ASC, 'name' => SORT_DESC]`). The method will automatically quote the column names unless a column contains some parenthesis (which means the column contains a DB expression). Note that if your order-by is an expression containing commas, you should always use an array to represent the order-by information. Otherwise, the method will not be able to correctly determine the order-by columns. Since version 2.0.7, an [[Expression]] object can be passed to specify the ORDER BY part explicitly in plain SQL. |
public $emulateExecution |
public $limit |
public $offset |
public $orderBy |