I have a CGridView, which normally shows a summary like this:
Displaying 1-4 of 4 results.
I need to apply a grouping into the underlying table before listing records in the CGridView, so I added corresponding property into CDBCriteria:
$criteria->group = 'fieldname';
Of course, this leads to the fact that total number of records (for output) should be less than without grouping. Actually, I got 1 record on my test table. But CGridView’s summary states the following:
[b]Displaying 1-1 of 4 results.
[/b]
This looks like a bug, imho. How can I make sure that the summary does always report total number of records correctly, even when "group by" SQL clause is involved?
As far as I can tell from generated logs, Yii runs separate query with "SELECT COUNT(DISTINCT…" for detecting total number of records. The problem is that this query somehow is not affected by the "group" property of the CDBCriteria. This property does only affect the second query, which actually fetches data from DB. This is why the number of rows available for user and summary do not match each other. How to fix this?
Thanks in advance.