diff options
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/album.class.php | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 780fa384..76857dc4 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -95,38 +95,38 @@ class Album extends database_object { */ public static function build_cache($ids,$extra=false) { - if ($ids) { - $idlist = '(' . implode(',', $ids) . ')'; + // Nothing to do if they pass us nothing + if (!is_array($ids) OR !count($ids)) { return false; } - $sql = "SELECT * FROM `album` WHERE `id` IN $idlist"; - $db_results = Dba::query($sql); - - while ($row = Dba::fetch_assoc($db_results)) { - parent::add_to_cache('album',$row['id'],$row); - } + $idlist = '(' . implode(',', $ids) . ')'; - // If we're extra'ing cache the extra info as well - if ($extra) { - $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" . - ",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb, artist.id AS artist_id,`song`.`album`". - "FROM `song` " . - "INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " . - "LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " . - "WHERE `song`.`album` IN $idlist GROUP BY `song`.`album`"; - $db_results = Dba::read($sql); - - while ($row = Dba::fetch_assoc($db_results)) { - $row['has_art'] = make_bool($row['has_art']); - $row['has_thumb'] = make_bool($row['has_thumb']); - parent::add_to_cache('album_extra',$row['album'],$row); - } // while rows - } // if extra - - return true; - } else { - return false; + $sql = "SELECT * FROM `album` WHERE `id` IN $idlist"; + $db_results = Dba::query($sql); + + while ($row = Dba::fetch_assoc($db_results)) { + parent::add_to_cache('album',$row['id'],$row); } + // If we're extra'ing cache the extra info as well + if ($extra) { + $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" . + ",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb, artist.id AS artist_id,`song`.`album`". + "FROM `song` " . + "INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " . + "LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " . + "WHERE `song`.`album` IN $idlist GROUP BY `song`.`album`"; + + $db_results = Dba::read($sql); + + while ($row = Dba::fetch_assoc($db_results)) { + $row['has_art'] = make_bool($row['has_art']); + $row['has_thumb'] = make_bool($row['has_thumb']); + parent::add_to_cache('album_extra',$row['album'],$row); + } // while rows + } // if extra + + return true; + } // build_cache /** |