diff options
author | momo-i <momo-i@ampache> | 2008-09-03 00:06:29 +0000 |
---|---|---|
committer | momo-i <momo-i@ampache> | 2008-09-03 00:06:29 +0000 |
commit | 7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5 (patch) | |
tree | 2636a9e425d21e6fe59c39ee253cb46b7742f22c /lib/class/tag.class.php | |
parent | f1866160fd048035f9f0f729f3d20283d64aa4a7 (diff) | |
download | ampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.tar.gz ampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.tar.bz2 ampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.zip |
Diffstat (limited to 'lib/class/tag.class.php')
-rw-r--r-- | lib/class/tag.class.php | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php index 22f4ea4a..ff02041d 100644 --- a/lib/class/tag.class.php +++ b/lib/class/tag.class.php @@ -77,16 +77,20 @@ class Tag extends database_object { */ public static function build_cache($ids) { - $idlist = '(' . implode(',',$ids) . ')'; + if ($ids) { + $idlist = '(' . implode(',',$ids) . ')'; - $sql = "SELECT * FROM `tag` WHERE `id` IN $idlist"; - $db_results = Dba::query($sql); + $sql = "SELECT * FROM `tag` WHERE `id` IN $idlist"; + $db_results = Dba::query($sql); - while ($row = Dba::fetch_assoc($db_results)) { - parent::add_to_cache('tag',$row['id'],$row); - } + while ($row = Dba::fetch_assoc($db_results)) { + parent::add_to_cache('tag',$row['id'],$row); + } - return true; + return true; + } else { + return false; + } } // build_cache @@ -96,25 +100,28 @@ class Tag extends database_object { */ public static function build_map_cache($type,$ids) { - $type = self::validate_type($type); - $idlist = '(' . implode(',',$ids) . ')'; + if ($ids) { + $type = self::validate_type($type); + $idlist = '(' . implode(',',$ids) . ')'; - $sql = "SELECT COUNT(`tag_map`.`id`) AS `count`,`tag`.`id`,`tag_map`.`object_id` FROM `tag_map` " . - "INNER JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " . - "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id` IN $idlist " . - "GROUP BY `tag_map`.`object_id` ORDER BY `count` DESC"; - $db_results = Dba::query($sql); + $sql = "SELECT COUNT(`tag_map`.`id`) AS `count`,`tag`.`id`,`tag_map`.`object_id` FROM `tag_map` " . + "INNER JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " . + "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id` IN $idlist " . + "GROUP BY `tag_map`.`object_id` ORDER BY `count` DESC"; + $db_results = Dba::query($sql); - while ($row = Dba::fetch_assoc($db_results)) { - $tags[$row['object_id']][] = $row; - } + while ($row = Dba::fetch_assoc($db_results)) { + $tags[$row['object_id']][] = $row; + } - - foreach ($tags as $id=>$entry) { - parent::add_to_cache('tag_map_' . $type,$id,$entry); - } + foreach ($tags as $id=>$entry) { + parent::add_to_cache('tag_map_' . $type,$id,$entry); + } - return true; + return true; + } else { + return false; + } } // build_map_cache |