In BaseDatabaseModel.php, at line 331 in Joomla 3.9, the clausules of the query used in getItems are cleared and a select count(*) is added, causing the wrong result, as it is not the same SELECT COUNT(*) than SELECT COUNT(DISTINCT id)).
IMHO there are two options to solve that:
The _getListCount function can be overrided in descendant classes when needed.
The way people would usually do this is by overriding the relevant methods in their model ...
either the public method
getTotal() method
or the protected method
_getListCount()
you are not obliged to use the default implementation,
that's why this method has protected access and not private access
That is what i am doing myself
Still i think something needs to be documented at the description of _getListCount() of BaseDatabaseModel about this
Labels |
Added:
J3 Issue
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-12-20 16:31:41 |
Closed_By | ⇒ | joomla-cms-bot |
Closed_By | joomla-cms-bot | ⇒ | Quy |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/22891
Personally, I'd suggest that this should be what happens when you start reaching more complex cases such as the one you're describing. The method is intended to cover the majority of common use cases, while I don't doubt that use of DISTINCT might be a frequent thing changing the query building logic really seems like something that should be taken care of in the model that needs the specialized behavior versus trying to change the core framework and affecting all query building logic.