From b362b74a92512c3986927c25c0be1c4341702829 Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 26 Jan 2009 11:40:35 +0000 Subject: Fixed pagination issue with count annotations function. git-svn-id: https://code.elgg.org/elgg/trunk@2616 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/annotations.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index 630c33b40..8c177ffff 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -661,7 +661,7 @@ if (!$count) { $query = "SELECT distinct e.*, $sum(ms.string) as sum "; } else { - $query = "SELECT count(e.guid) as num, $sum(ms.string) as sum "; + $query = "SELECT count(distinct e.guid) as num, $sum(ms.string) as sum "; } $query .= " from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}annotations a on a.entity_guid = e.guid JOIN {$CONFIG->dbprefix}metastrings ms on a.value_id=ms.id "; @@ -674,7 +674,7 @@ $query .= " $w and "; $query .= get_access_sql_suffix("a"); // now add access $query .= ' and ' . get_access_sql_suffix("e"); // now add access - $query .= ' group by e.guid'; + if (!$count) $query .= ' group by e.guid'; if (!$count) { $query .= ' order by sum ' . $orderdir; -- cgit v1.2.3