diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-05-12 02:52:50 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-05-12 02:52:50 +0000 |
commit | 693e26e2ad074f8cc9d37098a0568cd93ae30f52 (patch) | |
tree | 8588523335a337d0971df768da0456e325bb6b66 /lib/class/rating.class.php | |
parent | 003619c52c0370f03b9edb466addaaebac13ce41 (diff) | |
download | ampache-693e26e2ad074f8cc9d37098a0568cd93ae30f52.tar.gz ampache-693e26e2ad074f8cc9d37098a0568cd93ae30f52.tar.bz2 ampache-693e26e2ad074f8cc9d37098a0568cd93ae30f52.zip |
commit of the patches from codeoverload to implement tagging, will not work without manual modification of database, yes.. this commit breaks things cope
Diffstat (limited to 'lib/class/rating.class.php')
-rw-r--r-- | lib/class/rating.class.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index 51555c10..0519672e 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -56,14 +56,25 @@ class Rating { return true; } // Constructor - + public static function build_cache($type, $ids) { + $idlist = '(' . implode(',', $ids) . ')'; + $sql = "SELECT `rating`, object_id FROM `rating` WHERE `user`='$user_id' AND `object_id` in $idlist AND `object_type`='$type'"; + global $rating_cache; + $rating_cache = array(); + $db_results = Dba::query($sql); + while ($results = Dba::fetch_assoc($db_results)) { + $rating_cache[intval($results['object_id'])] = $results; + } + } /** * get_user * Get the user's rating this is based off the currently logged * in user. It returns the value */ - public function get_user($user_id) { - + public function get_user($user_id) { + global $rating_cache; + if (isset($rating_cache[intval($this->id)])); + return $rating_cache[intval($this->id)]['rating']; $user_id = Dba::escape($user_id); $sql = "SELECT `rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'"; |