aboutsummaryrefslogtreecommitdiffstats
path: root/search.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2014-09-08 09:46:50 +0000
committerplegall <plg@piwigo.org>2014-09-08 09:46:50 +0000
commit478249d5d040bd26bbfadee420161da103fb47a9 (patch)
treef3f7acedcbf60008b4b8f9af01d50425862048e0 /search.php
parenta7646af2d972e90b79238c6ae1be7084c08cec0a (diff)
bug 3136: in author search listbox, do no count photos twice if they are associated to 2 albums
git-svn-id: http://piwigo.org/svn/trunk@29430 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'search.php')
-rw-r--r--search.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/search.php b/search.php
index be2607196..e680ae048 100644
--- a/search.php
+++ b/search.php
@@ -214,7 +214,7 @@ if (count($available_tags) > 0)
$query = '
SELECT
author,
- COUNT(*) AS counter
+ id
FROM '.IMAGES_TABLE.' AS i
JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.image_id = i.id
'.get_sql_condition_FandF(
@@ -226,10 +226,28 @@ SELECT
' WHERE '
).'
AND author IS NOT NULL
- GROUP BY author
+ GROUP BY author, id
ORDER BY author
;';
-$authors = query2array($query);
+$author_counts = array();
+$result = pwg_query($query);
+while ($row = pwg_db_fetch_assoc($result))
+{
+ if (!isset($author_counts[ $row['author'] ]))
+ {
+ $author_counts[ $row['author'] ] = 0;
+ }
+
+ $author_counts[ $row['author'] ]++;
+}
+
+foreach ($author_counts as $author => $counter)
+{
+ $authors[] = array(
+ 'author' => $author,
+ 'counter' => $counter,
+ );
+}
$template->assign('AUTHORS', $authors);