Changeset 2087
- Timestamp:
- Sep 12, 2007, 5:37:01 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_tag.inc.php
r1900 r2087 8 8 // | last update : $Date$ 9 9 // | last modifier : $Author$ 10 // | revision : $Revision$11 10 // | revision : $Revision$ 12 11 // +-----------------------------------------------------------------------+ … … 40 39 { 41 40 // we can find top fatter tags among reachable images 42 $tags_query = ' 43 SELECT id, name, url_name, count(*) counter 44 FROM '.IMAGE_TAG_TABLE.' 45 INNER JOIN '.TAGS_TABLE.' ON tag_id = id'; 46 47 $where_tag_img = 48 get_sql_condition_FandF 41 $query = ' 42 SELECT tag_id, COUNT(DISTINCT(it.image_id)) counter 43 FROM '.IMAGE_CATEGORY_TABLE.' ic 44 INNER JOIN '.IMAGE_TAG_TABLE.' it ON ic.image_id=it.image_id'.get_sql_condition_FandF 49 45 ( 50 46 array … … 52 48 'forbidden_categories' => 'category_id', 53 49 'visible_categories' => 'category_id', 54 'visible_images' => 'i mage_id'50 'visible_images' => 'ic.image_id' 55 51 ), 56 'WHERE' 57 ); 58 59 if (!empty($where_tag_img)) 60 { 61 // first we need all reachable image ids 62 $images_query = ' 63 SELECT DISTINCT image_id 64 FROM '.IMAGE_CATEGORY_TABLE.' 65 '.$where_tag_img.' 66 ;'; 67 $image_ids = array_from_query($images_query, 'image_id'); 68 if ( empty($image_ids) ) 69 { 70 return array(); 71 } 72 $tags_query.= ' 73 WHERE image_id IN ('. 74 wordwrap( 75 implode(', ', $image_ids), 76 80, 77 "\n" 78 ).')'; 79 } 80 81 $tags_query.= ' 82 GROUP BY tag_id 83 ;'; 84 85 $result = pwg_query($tags_query); 52 ' 53 WHERE' 54 ).' 55 GROUP BY tag_id'; 56 $tag_counters = simple_hash_from_query($query, 'tag_id', 'counter'); 57 58 if ( empty($tag_counters) ) 59 { 60 return array(); 61 } 62 63 $query = ' 64 SELECT id, name, url_name 65 FROM '.TAGS_TABLE; 66 $result = pwg_query($query); 86 67 $tags = array(); 87 68 while ($row = mysql_fetch_assoc($result)) 88 69 { 89 array_push($tags, $row); 90 } 91 70 $counter = @$tag_counters[ $row['id'] ]; 71 if ( $counter ) 72 { 73 $row['counter'] = $counter; 74 array_push($tags, $row); 75 } 76 } 92 77 return $tags; 93 78 }
Note: See TracChangeset
for help on using the changeset viewer.