summaryrefslogtreecommitdiffstats
path: root/lib/class/artist.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-12 05:58:17 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-12 05:58:17 +0000
commit3634ba80946b818de7f0505ed44d947e70dd41ec (patch)
tree03749fb9cc1f1fc6ef157ac187cea48f1f1a7098 /lib/class/artist.class.php
parent3e36e0b01e843ec8d4e8a63a72e5f7425921dab8 (diff)
downloadampache-3634ba80946b818de7f0505ed44d947e70dd41ec.tar.gz
ampache-3634ba80946b818de7f0505ed44d947e70dd41ec.tar.bz2
ampache-3634ba80946b818de7f0505ed44d947e70dd41ec.zip
added in some caching and add the database upgrade that will make the taging mostly work
Diffstat (limited to 'lib/class/artist.class.php')
-rw-r--r--lib/class/artist.class.php44
1 files changed, 28 insertions, 16 deletions
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 73d5bef7..f5591018 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2008 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -22,7 +22,7 @@
/**
* Artist Class
*/
-class Artist {
+class Artist extends database_object {
/* Variables from DB */
public $id;
@@ -76,30 +76,42 @@ class Artist {
return $artist;
} // construct_from_array
- public static function build_cache($ids, $fields='*') {
- $idlist = '(' . implode(',', $ids) . ')';
- $sql = "SELECT $fields FROM artist WHERE id in $idlist";
- $db_results = Dba::query($sql);
- global $artist_cache;
- $artist_cache = array();
- while ($results = Dba::fetch_assoc($db_results)) {
- $artist_cache[intval($results['id'])] = $results;
- }
- }
+
+ /**
+ * this attempts to build a cache of the data from the passed albums all in one query
+ */
+ public static function build_cache($ids) {
+ $idlist = '(' . implode(',', $ids) . ')';
+
+ $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);
+ }
+
+ } // build_cache
+
/**
* _get_info
* get's the vars for $this out of the database taken from the object
*/
private function _get_info() {
- global $artist_cache;
- if (isset($artist_cache[intval($this->id)]))
- return $artist_cache[intval($this->id)];
+
+ $id = intval($this->id);
+
+ if (parent::is_cached('artist',$id)) {
+ return parent::get_from_cache('artist',$id);
+ }
+
/* Grab the basic information from the catalog and return it */
- $sql = "SELECT * FROM artist WHERE id='" . Dba::escape($this->id) . "'";
+ $sql = "SELECT * FROM artist WHERE id='$id'";
$db_results = Dba::query($sql);
$results = Dba::fetch_assoc($db_results);
+ parent::add_to_cache('artist',$id,$results);
+
return $results;
} // _get_info