Added `QueryInterface::emulateExecution()`, which allows preventing of
the actual query execution.
This allows to cancel `DataProvider` preventing search query execution
in case search model is invalid:
``` php
public function search($params)
{
$query = Item::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
$query->emulateExecution(); // No SQL execution will be done
return $dataProvider;
}
```
This also fix unecessary query in case of `via()` usage. See #12390.
fixes#12390fixes#6373close#12708
* query-filter:
added CHANGELOG lines
added tests for redis
added proper tests for elasticsearch
removed unnecessary code duplication
adjusted tests
typo
renamed Query::filter() to Query::filterWhere()
reverted elasticsearch rename of filter
Adjusted search model code generated by Gii CRUD generator
Added support for arbitrary number of parameters for NOT, AND, OR in filter methods of Query
Gii CRUD generator now uses new addFilter method
Query::filter() adjustments
fixes#2002
Added tests for Query::filter()
Conflicts:
framework/db/QueryTrait.php