From 17ff1d5f0f60e29cf12509be663c6f7b2c97893a Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sat, 9 Jul 2005 19:32:21 +0000 Subject: fixed song class --- lib/song.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lib/song.php') diff --git a/lib/song.php b/lib/song.php index 0e847ad9..7c9a3282 100644 --- a/lib/song.php +++ b/lib/song.php @@ -53,5 +53,39 @@ function format_song($song) { } // format_song +/** + * get_popular_songs + * This returns the current popular songs + * @package Stream + * @catagory Get + */ +function get_popular_songs( $threshold, $type, $user_id = '' ) { + + $dbh = dbh(); + + if ( $type == 'your' ) { + $sql = "SELECT object_id FROM object_count" . + " WHERE object_type = 'song'" . + " AND userid = '$user_id'" . + " ORDER BY count DESC LIMIT $threshold"; + } + else { + $sql = "SELECT object_id FROM object_count" . + " WHERE object_type = 'song'" . + " ORDER BY count DESC LIMIT $threshold"; + } + + $db_result = mysql_query($sql, $dbh); + $songs = array(); + + while ( $id = mysql_fetch_array($db_result) ) { + $songs[] = $id[0]; + } + + return $songs; + +} // get_popular_songs() + + ?> -- cgit