summaryrefslogtreecommitdiffstats
path: root/lib/song.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/song.php')
-rw-r--r--lib/song.php93
1 files changed, 6 insertions, 87 deletions
diff --git a/lib/song.php b/lib/song.php
index fc987943..6d393ac9 100644
--- a/lib/song.php
+++ b/lib/song.php
@@ -27,56 +27,6 @@
* and the like
*/
-/*!
- @function get_songs
- @discussion pass a sql statement, and it gets full song info and returns
- an array of the goods.. can be set to format them as well
-*/
-function get_songs($sql, $action=0) {
-
- $db_results = mysql_query($sql, dbh());
- while ($r = mysql_fetch_array($db_results)) {
- $results[] = $r['id'];
- }
-
- return $results;
-
-
-} // get_songs
-
-/**
- * get_songs_from_type
- * This gets an array of songs based on the type and from the results array
- * can pull songs from an array of albums, artists whatever
- */
-function get_songs_from_type($type,$results,$artist_id='') {
-
- // Init the array
- $songs = array();
-
- $type = sql_escape($type);
-
- $sql = "SELECT id FROM song WHERE (";
-
- foreach ($results as $value) {
- $value = sql_escape($value);
- $sql .= "`$type`='$value' OR ";
- }
-
- // Run the long query
- $sql = rtrim($sql,'OR ') . ')';
- $sql .= " ORDER BY `track`";
-
- $db_results = mysql_query($sql,dbh());
-
- while ($r = mysql_fetch_assoc($db_results)) {
- $songs[] = $r['id'];
- }
-
- return $songs;
-
-} // get_song_from_type
-
/**
* get_recently_played
* This function returns the last X songs that have been played
@@ -105,52 +55,21 @@ function get_recently_played($user_id='') {
} // get_recently_played
-/**
- * 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()
-
/**
* get_song_id_from_file
* This function takes a filename and returns it's best guess for a song id
+ * It is used by some of the localplay methods to go from filename to ampache
+ * song record for items that are manualy entered into the clients
*/
function get_song_id_from_file($filename) {
- $filename = sql_escape($filename);
+ $filename = Dba::escape($filename);
- $sql = "SELECT id FROM song WHERE file LIKE '%$filename'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT `id` FROM `song` WHERE `file` LIKE '%$filename'";
+ $db_results = Dba::query($sql);
- $results = mysql_fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
return $results['id'];