diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-04-20 19:09:23 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-04-20 19:09:23 +0000 |
commit | 6d9533844cf95de3f7e013600b7eb84f0518dded (patch) | |
tree | 60a408b5b9ef8208cf82d111fe9bbb1197945474 | |
parent | 8cd66f1aeb9596c60d8e81b83b404dfeea9ab167 (diff) | |
download | ampache-6d9533844cf95de3f7e013600b7eb84f0518dded.tar.gz ampache-6d9533844cf95de3f7e013600b7eb84f0518dded.tar.bz2 ampache-6d9533844cf95de3f7e013600b7eb84f0518dded.zip |
new get_song_id_from_file function for Infamy
-rw-r--r-- | lib/song.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/song.php b/lib/song.php index b24c94db..81095cc1 100644 --- a/lib/song.php +++ b/lib/song.php @@ -87,4 +87,28 @@ function get_popular_songs( $threshold, $type, $user_id = '' ) { } // get_popular_songs() + +/** + * get_song_id_from_file + * This function takes a filename and returns it's best guess for a song id + */ +function get_song_id_from_file($filename) { + + $filename = sql_escape($filename); + + $sql = "SELECT id FROM song WHERE file='$filename'"; + $db_results = mysql_query($sql, dbh()); + + $results = mysql_fetch_assoc($db_results); + + if (!$results['id']) { + $sql = "SELECT id FROM song WHERE file='%$filename%'"; + $db_results = mysql_query($sql, dbh()); + $results = mysql_fetch_assoc($db_results); + } + + return $results['id']; + +} // get_song_id_from_file + ?> |