- 13
- Sep
If you are using "SELECT DISTINCT" for pager_query you may get wrong pagination (more pages than you expected).
Look into the function pager_query, we can find the statements:
if (!isset($count_query)) {
$count_query = preg_replace(array('/SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''), $query);
}
$count_query is the fourth optional argument of pager_query. If you used "SELECT DISTINCT" in your query and not set this argument. The "SELECT DISTINCT" will be replaced by "SELECT COUNT(*) FROM" and you will get wrong number of total items, so does total pages.
So the fourth argument is needed if you have "SELECT DISTINCT" in your query.
Difference