diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-09 06:35:24 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-09 06:35:24 +0000 |
commit | 699a85cb82f5b8cec9439a29c2f3312ae84b77e0 (patch) | |
tree | dad8be2db019f5c1fb51e417c0e9e04853dded72 /lib/class | |
parent | 796c2692d0cfa4641e0c47700371c24a01412ed1 (diff) | |
download | ampache-699a85cb82f5b8cec9439a29c2f3312ae84b77e0.tar.gz ampache-699a85cb82f5b8cec9439a29c2f3312ae84b77e0.tar.bz2 ampache-699a85cb82f5b8cec9439a29c2f3312ae84b77e0.zip |
fixed some ratings stuff, fixed some searching stuff as well
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/browse.class.php | 6 | ||||
-rw-r--r-- | lib/class/dba.class.php | 1 | ||||
-rw-r--r-- | lib/class/rating.class.php | 12 |
3 files changed, 11 insertions, 8 deletions
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index 42152bd2..076b8849 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -181,7 +181,7 @@ class Browse { // First we need to get the SQL statement we are going to run // This has to run against any possible filters (dependent on type) $sql = self::get_sql(); -debug_event('sql',$sql,'1'); + $db_results = Dba::query($sql); $results = array(); @@ -422,7 +422,9 @@ debug_event('sql',$sql,'1'); // Limit is based on the users preferences $limit = $GLOBALS['user']->prefs['offset_limit'] ? $GLOBALS['user']->prefs['offset_limit'] : '25'; - $object_ids = array_slice($object_ids,self::$start,$limit); + if (count($object_ids) > $start) { + $object_ids = array_slice($object_ids,self::$start,$limit); + } switch ($_SESSION['browse']['type']) { case 'song': diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php index 70bd47f5..f396d0f9 100644 --- a/lib/class/dba.class.php +++ b/lib/class/dba.class.php @@ -87,6 +87,7 @@ class Dba { $result = mysql_fetch_assoc($resource); if (!$result) { +// debug_event('fetch_assoc',self::$_sql,'1'); return array(); } diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index 1ddd842a..ff7b940d 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -64,12 +64,12 @@ class Rating { $user_id = Dba::escape($user_id); - $sql = "SELECT `score` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'"; + $sql = "SELECT `rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'"; $db_results = Dba::query($sql); $results = Dba::fetch_assoc($db_results); - return $results['score']; + return $results['rating']; } // get_user @@ -82,14 +82,14 @@ class Rating { */ public function get_average() { - $sql = "SELECT `score` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type'"; + $sql = "SELECT `rating` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type'"; $db_results = Dba::query($sql); $i = 0; while ($r = Dba::fetch_assoc($db_results)) { $i++; - $total += $r['score']; + $total += $r['rating']; } // while we're pulling results if ($total > 0) { @@ -123,11 +123,11 @@ class Rating { $db_results = Dba::query($sql); if ($existing = Dba::fetch_assoc($db_results)) { - $sql = "UPDATE `rating` SET `score`='$score' WHERE `id`='" . $existing['id'] . "'"; + $sql = "UPDATE `rating` SET `rating`='$score' WHERE `id`='" . $existing['id'] . "'"; $db_results = Dba::query($sql); } else { - $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`score`,`user`) VALUES " . + $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`rating`,`user`) VALUES " . " ('$this->id','$this->type','$score','" . $GLOBALS['user']->id . "')"; $db_results = Dba::query($sql); } |