Show
Ignore:
Timestamp:
09/02/08 17:06:29 (4 months ago)
Author:
momo-i
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/class/artist.class.php

    r1698 r1736  
    7979         */ 
    8080        public static function build_cache($ids,$extra=false) { 
    81                 $idlist = '(' . implode(',', $ids) . ')'; 
    82  
    83                 $sql = "SELECT * FROM `artist` WHERE `id` IN $idlist"; 
    84                 $db_results = Dba::query($sql); 
    85  
    86                 while ($row = Dba::fetch_assoc($db_results)) { 
    87                         parent::add_to_cache('artist',$row['id'],$row);  
     81                if($ids) { 
     82                        $idlist = '(' . implode(',', $ids) . ')'; 
     83 
     84                        $sql = "SELECT * FROM `artist` WHERE `id` IN $idlist"; 
     85                        $db_results = Dba::query($sql); 
     86 
     87                        while ($row = Dba::fetch_assoc($db_results)) { 
     88                                parent::add_to_cache('artist',$row['id'],$row);  
     89                        } 
     90 
     91                        // If we need to also pull the extra information, this is normally only used when we are doing the human display 
     92                        if ($extra) {  
     93                                $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " . 
     94                                        "WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`"; 
     95                                $db_results = Dba::query($sql); 
     96 
     97                                while ($row = Dba::fetch_assoc($db_results)) {  
     98                                        parent::add_to_cache('artist_extra',$row['artist'],$row);  
     99                                }  
     100 
     101                        } // end if extra 
     102 
     103                        return true; 
     104                } else { 
     105                        return false; 
    88106                } 
    89  
    90                 // If we need to also pull the extra information, this is normally only used when we are doing the human display 
    91                 if ($extra) {  
    92                         $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " . 
    93                                 "WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`"; 
    94                         $db_results = Dba::query($sql); 
    95  
    96                         while ($row = Dba::fetch_assoc($db_results)) {  
    97                                 parent::add_to_cache('artist_extra',$row['artist'],$row);  
    98                         }  
    99  
    100                 } // end if extra  
    101107 
    102108        } // build_cache