summaryrefslogtreecommitdiffstats
path: root/lib/class/album.class.php
diff options
context:
space:
mode:
authormomo-i <momo-i@ampache>2008-09-03 00:06:29 +0000
committermomo-i <momo-i@ampache>2008-09-03 00:06:29 +0000
commit7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5 (patch)
tree2636a9e425d21e6fe59c39ee253cb46b7742f22c /lib/class/album.class.php
parentf1866160fd048035f9f0f729f3d20283d64aa4a7 (diff)
downloadampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.tar.gz
ampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.tar.bz2
ampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.zip
Diffstat (limited to 'lib/class/album.class.php')
-rw-r--r--lib/class/album.class.php50
1 files changed, 28 insertions, 22 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 049331ff..780fa384 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -95,31 +95,37 @@ class Album extends database_object {
*/
public static function build_cache($ids,$extra=false) {
- $idlist = '(' . implode(',', $ids) . ')';
+ if ($ids) {
+ $idlist = '(' . implode(',', $ids) . ')';
- $sql = "SELECT * FROM `album` WHERE `id` IN $idlist";
- $db_results = Dba::query($sql);
+ $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);
- }
+ 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
+ // 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;
+ }
} // build_cache