Changeset 29430 for trunk/search.php


Ignore:
Timestamp:
09/08/14 11:46:50 (6 years ago)
Author:
plg
Message:

bug 3136: in author search listbox, do no count photos twice if they are associated to 2 albums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/search.php

    r28744 r29430  
    215215SELECT 
    216216    author, 
    217     COUNT(*) AS counter 
     217    id 
    218218  FROM '.IMAGES_TABLE.' AS i 
    219219    JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.image_id = i.id 
     
    227227    ).' 
    228228    AND author IS NOT NULL 
    229   GROUP BY author 
     229  GROUP BY author, id 
    230230  ORDER BY author 
    231231;'; 
    232 $authors = query2array($query); 
     232$author_counts = array(); 
     233$result = pwg_query($query); 
     234while ($row = pwg_db_fetch_assoc($result)) 
     235{ 
     236  if (!isset($author_counts[ $row['author'] ])) 
     237  { 
     238    $author_counts[ $row['author'] ] = 0; 
     239  } 
     240   
     241  $author_counts[ $row['author'] ]++; 
     242} 
     243 
     244foreach ($author_counts as $author => $counter) 
     245{ 
     246  $authors[] = array( 
     247    'author' => $author, 
     248    'counter' => $counter, 
     249    ); 
     250} 
    233251 
    234252$template->assign('AUTHORS', $authors); 
Note: See TracChangeset for help on using the changeset viewer.