Closed strtob closed 2 years ago
due to the fact that dataprovider use count(*) the subquery is removed in "ActiveDataProvider.php"
/**
* {@inheritdoc}
*/
protected function prepareTotalCount() {
if (!$this->query instanceof QueryInterface) {
throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.');
}
$query = clone $this->query;
return (int) $query->limit(-1)->offset(-1)->orderBy([])->count('*', $this->db);
}
How fix this?
Maybe to try with andHave() instead andWhere() for filesCount?
Can you show more of the query?
You've got two select
s, the last one will overwrite the first.
If your query is distinct
or has a groupBy
, having
, union
clause the count
will wrap the query.
It is not Yii2 error. You can't use WHERE on column alias, just HAVE. You can only use column aliases in GROUP BY, ORDER BY, or HAVING clauses.
What steps will reproduce the problem?
use dataprovider with this setup:
What is the expected result?
no error
What do you get instead?
It seems that the subquery is not used by the getTotalCount() function. Any ideas?
Additional info