diff options
Diffstat (limited to 'lib/song.php')
-rw-r--r-- | lib/song.php | 34 |
1 files changed, 34 insertions, 0 deletions
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() + + ?> |