#615 Fixed bug on multi column queries - wrong count resulting in strange effects in the display of results

SVN:trunk[2422]
This commit is contained in:
Romain Quetiez
2012-11-12 14:34:39 +00:00
parent 6987db54b5
commit 3b93fcff3c

View File

@@ -311,8 +311,13 @@ class SQLQuery
{
if (count($aSelectedIdFields) > 0)
{
$sIDFields = implode(', ', $aSelectedIdFields);
$sSQL = "SELECT COUNT(DISTINCT $sIDFields) AS COUNT FROM $sFrom WHERE $sWhere";
$aCountFields = array();
foreach ($aSelectedIdFields as $sFieldExpr)
{
$aCountFields[] = "COALESCE($sFieldExpr, 0)"; // Null values are excluded from the count
}
$sCountFields = implode(', ', $aCountFields);
$sSQL = "SELECT COUNT(DISTINCT $sCountFields) AS COUNT FROM $sFrom WHERE $sWhere";
}
else
{