[eluser]tahpot[/eluser]
Hi,
This bug occurs with the MySQL driver, most likely with others as well.
Codigniter assumes that calling "count (*)" over a query will always produce the total number of results for the given query (see $_count_string in mysql_driver.php). This is incorrect. When using "group by", count(*) doesn't produce a count of all the rows, it produces a result set, counting the number of entries for the given group by column(s).
To fix this I suggest that that the count_all_results() method should be overridden by the respective driver and implement a more driver specific solution (in this case with MySQL, make use of the SQL_CALC_FOUND_ROWS, possibly performing the query with limit = 1 first to get the value).
While I'm here, I also suggest adding a second parameter to count_all_results(), $reset_select=true. That way, it's possible to fetch the number of rows for a query and then fetch the results without having to completely rebuild the active record class.
Cheers,
Chris