mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fixes #2022: Added info about yii\db\Query::andFilterCompare()
to guide
This commit is contained in:
@ -351,6 +351,20 @@ Like [[yii\db\Query::andWhere()|andWhere()]] and [[yii\db\Query::orWhere()|orWhe
|
||||
[[yii\db\Query::andFilterWhere()|andFilterWhere()]] and [[yii\db\Query::orFilterWhere()|orFilterWhere()]]
|
||||
to append additional filter conditions to the existing one.
|
||||
|
||||
Additionally, there is [[yii\db\Query::andFilterCompare()]] that can intelligently determine operator based on what's
|
||||
in the value:
|
||||
|
||||
```php
|
||||
$query->andFilterCompare('name', 'John Doe');
|
||||
$query->andFilterCompare('rating', '>9');
|
||||
$query->andFilterCompare('value', '<=100');
|
||||
```
|
||||
|
||||
You can also specify operator explicitly:
|
||||
|
||||
```php
|
||||
$query->andFilterCompare('name', 'Doe', 'like');
|
||||
```
|
||||
|
||||
### [[yii\db\Query::orderBy()|orderBy()]] <span id="order-by"></span>
|
||||
|
||||
|
@ -395,9 +395,11 @@ class PostSearch extends Post
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
> Tip: See [Query Builder](db-query-builder.md) and especially [Filter Conditions](db-query-builder.md#filter-conditions)
|
||||
> to learn how to build filtering query.
|
||||
|
||||
You can use this function in the controller to get the dataProvider for the GridView:
|
||||
|
||||
```php
|
||||
|
Reference in New Issue
Block a user