summaryrefslogtreecommitdiffstats
path: root/lib/class/random.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-19 08:50:35 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-19 08:50:35 +0000
commitbc36b9d282aff16dfc794819919897103c94b9bd (patch)
tree1d3cec755afbf08a595c4164d47a219b2dfa7ed3 /lib/class/random.class.php
parentd560bb1c7b7e675ad72af0731df18757bf9d5700 (diff)
downloadampache-bc36b9d282aff16dfc794819919897103c94b9bd.tar.gz
ampache-bc36b9d282aff16dfc794819919897103c94b9bd.tar.bz2
ampache-bc36b9d282aff16dfc794819919897103c94b9bd.zip
added some basic random functionality, need to make the advanced page
Diffstat (limited to 'lib/class/random.class.php')
-rw-r--r--lib/class/random.class.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/class/random.class.php b/lib/class/random.class.php
index 58be0463..b2081539 100644
--- a/lib/class/random.class.php
+++ b/lib/class/random.class.php
@@ -39,6 +39,54 @@ class Random {
} // constructor
/**
+ * album
+ * This returns the ID of a random album, nothing special
+ */
+ public static function album() {
+
+ $sql = "SELECT `id` FROM `album` ORDER BY RAND() LIMIT 1";
+ $db_results = Dba::query($sql);
+
+ $results = Dba::fetch_assoc($db_results);
+
+ return $results['id'];
+
+ } // album
+
+ /**
+ * artist
+ * This returns the ID of a random artist, nothing special here for now
+ */
+ public static function artist() {
+
+ $sql = "SELECT `id` FROM `artist` ORDER BY RAND() LIMIT 1";
+ $db_results = Dba::query($sql);
+
+ $results = Dba::fetch_assoc($db_results);
+
+ return $results['id'];
+
+ } // artist
+
+ /**
+ * playlist
+ * This returns a random Playlist with songs little bit of extra
+ * logic require
+ */
+ public static function playlist() {
+
+ $sql = "SELECT `playlist`.`id` FROM `playlist` LEFT JOIN `playlist_data` " .
+ " ON `playlist`.`id`=`playlist_data`.`playlist` WHERE `playlist_data`.`object_id` IS NOT NULL " .
+ " ORDER BY RAND()";
+ $db_results = Dba::query($sql);
+
+ $results = Dba::fetch_assoc($db_results);
+
+ return $results['id'];
+
+ } // playlist
+
+ /**
* play_url
* This generates a random play url based on the passed type
* and returns it