Skip to content

Commit

Permalink
bug 3136: in author search listbox, do no count photos twice if they …
Browse files Browse the repository at this point in the history
…are associated to 2 albums

git-svn-id: http://piwigo.org/svn/trunk@29430 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Sep 8, 2014
1 parent a7646af commit 478249d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions search.php
Expand Up @@ -214,7 +214,7 @@
$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(
Expand All @@ -226,10 +226,28 @@
' 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);

Expand Down

0 comments on commit 478249d

Please sign in to comment.