summaryrefslogtreecommitdiffstats
path: root/lib/class/artist.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/artist.class.php
parentf1866160fd048035f9f0f729f3d20283d64aa4a7 (diff)
downloadampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.tar.gz
ampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.tar.bz2
ampache-7a6e4825d9738bd4c51deeb2eff942f2ffcbc5c5.zip
Diffstat (limited to 'lib/class/artist.class.php')
-rw-r--r--lib/class/artist.class.php36
1 files changed, 21 insertions, 15 deletions
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 1b72d7df..ae742ded 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -78,26 +78,32 @@ class Artist extends database_object {
* this attempts to build a cache of the data from the passed albums all in one query
*/
public static function build_cache($ids,$extra=false) {
- $idlist = '(' . implode(',', $ids) . ')';
+ if($ids) {
+ $idlist = '(' . implode(',', $ids) . ')';
- $sql = "SELECT * FROM `artist` WHERE `id` IN $idlist";
- $db_results = Dba::query($sql);
+ $sql = "SELECT * FROM `artist` WHERE `id` IN $idlist";
+ $db_results = Dba::query($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('artist',$row['id'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('artist',$row['id'],$row);
+ }
- // If we need to also pull the extra information, this is normally only used when we are doing the human display
- if ($extra) {
- $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " .
- "WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`";
- $db_results = Dba::query($sql);
+ // If we need to also pull the extra information, this is normally only used when we are doing the human display
+ if ($extra) {
+ $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " .
+ "WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`";
+ $db_results = Dba::query($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('artist_extra',$row['artist'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('artist_extra',$row['artist'],$row);
+ }
+
+ } // end if extra
- } // end if extra
+ return true;
+ } else {
+ return false;
+ }
} // build_cache