diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2012-09-20 11:02:12 -0400 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2012-09-20 11:22:42 -0400 |
commit | de300b2c167db9f7e9771c13e1f9be2a8589bdb8 (patch) | |
tree | b991cb79cc0ad038672cf419a9171c864973a3b5 /lib/class/song.class.php | |
parent | 0086e772dbd5a8838312c498855a70a39c00fe42 (diff) | |
download | ampache-de300b2c167db9f7e9771c13e1f9be2a8589bdb8.tar.gz ampache-de300b2c167db9f7e9771c13e1f9be2a8589bdb8.tar.bz2 ampache-de300b2c167db9f7e9771c13e1f9be2a8589bdb8.zip |
Cosmetics: Song::build_cache
Diffstat (limited to 'lib/class/song.class.php')
-rw-r--r-- | lib/class/song.class.php | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 6529bde2..0b726aec 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -95,31 +95,35 @@ class Song extends database_object implements media { /** * build_cache - * This attempts to reduce # of queries by asking for everything in the browse - * all at once and storing it in the cache, this can help if the db connection - * is the slow point + * + * This attempts to reduce queries by asking for everything in the + * browse all at once and storing it in the cache, this can help if the + * db connection is the slow point. */ public static function build_cache($song_ids) { - if (!is_array($song_ids) OR !count($song_ids)) { return false; } + if (!is_array($song_ids) || !count($song_ids)) { return false; } $idlist = '(' . implode(',', $song_ids) . ')'; // Song data cache - $sql = "SELECT song.id,file,catalog,album,year,artist,". - "title,bitrate,rate,mode,size,time,track,played,song.enabled,update_time,tag_map.tag_id,". - "mbid,". - "addition_time FROM `song` " . - "LEFT JOIN `tag_map` ON `tag_map`.`object_id`=`song`.`id` AND `tag_map`.`object_type`='song' " . - "WHERE `song`.`id` IN $idlist"; + $sql = 'SELECT `song`.`id`, `file`, `catalog`, `album`, ' . + '`year`, `artist`, `title`, `bitrate`, `rate`, ' . + '`mode`, `size`, `time`, `track`, `played`, ' . + '`song`.`enabled`, `update_time`, `tag_map`.`tag_id`, '. + '`mbid`, `addition_time` ' . + 'FROM `song` LEFT JOIN `tag_map` ' . + 'ON `tag_map`.`object_id`=`song`.`id` ' . + "AND `tag_map`.`object_type`='song' " . + "WHERE `song`.`id` IN $idlist"; $db_results = Dba::read($sql); while ($row = Dba::fetch_assoc($db_results)) { - parent::add_to_cache('song',$row['id'],$row); - $artists[$row['artist']] = $row['artist']; - $albums[$row['album']] = $row['album']; + parent::add_to_cache('song', $row['id'], $row); + $artists[$row['artist']] = $row['artist']; + $albums[$row['album']] = $row['album']; if ($row['tag_id']) { - $tags[$row['tag_id']] = $row['tag_id']; + $tags[$row['tag_id']] = $row['tag_id']; } } @@ -131,7 +135,7 @@ class Song extends database_object implements media { // If we're rating this then cache them as well if (Config::get('ratings')) { - Rating::build_cache('song',$song_ids); + Rating::build_cache('song', $song_ids); } // Build a cache for the song's extended table @@ -139,7 +143,7 @@ class Song extends database_object implements media { $db_results = Dba::read($sql); while ($row = Dba::fetch_assoc($db_results)) { - parent::add_to_cache('song_data',$row['song_id'],$row); + parent::add_to_cache('song_data', $row['song_id'], $row); } return true; |