Skip to content
Snippets Groups Projects
Commit 8de4163b authored by Robin Appelman's avatar Robin Appelman
Browse files

fix searching artists and albums

parent 25213a79
No related branches found
No related tags found
No related merge requests found
...@@ -121,14 +121,19 @@ class OC_MEDIA_COLLECTION{ ...@@ -121,14 +121,19 @@ class OC_MEDIA_COLLECTION{
* @return array the list of artists found * @return array the list of artists found
*/ */
static public function getArtists($search='%',$exact=false){ static public function getArtists($search='%',$exact=false){
$uid=self::$uid;
if(empty($uid)){
$uid=self::$uid=$_SESSION['user_id'];
}
if(!$exact and $search!='%'){ if(!$exact and $search!='%'){
$search="%$search%"; $search="%$search%";
}elseif($search==''){ }elseif($search==''){
$search='%'; $search='%';
} }
$query=OC_DB::prepare("SELECT DISTINCT *PREFIX*media_artists.artist_name AS artist_name , *PREFIX*media_artists.artist_id AS artist_id FROM *PREFIX*media_artists $query=OC_DB::prepare("SELECT DISTINCT artist_name, artist_id FROM *PREFIX*media_artists
INNER JOIN *PREFIX*media_songs ON *PREFIX*media_artists.artist_id=*PREFIX*media_songs.song_artist WHERE artist_name LIKE ? AND *PREFIX*media_songs.song_user=? ORDER BY artist_name"); INNER JOIN *PREFIX*media_songs ON artist_id=song_artist WHERE artist_name LIKE ? AND song_user=? ORDER BY artist_name");
return $query->execute(array($search,self::$uid))->fetchAll(); $result=$query->execute(array($search,self::$uid));
return $result->fetchAll();
} }
/** /**
...@@ -159,6 +164,10 @@ class OC_MEDIA_COLLECTION{ ...@@ -159,6 +164,10 @@ class OC_MEDIA_COLLECTION{
* @return array the list of albums found * @return array the list of albums found
*/ */
static public function getAlbums($artist=0,$search='%',$exact=false){ static public function getAlbums($artist=0,$search='%',$exact=false){
$uid=self::$uid;
if(empty($uid)){
$uid=self::$uid=$_SESSION['user_id'];
}
$cmd="SELECT DISTINCT album_name, album_artist, album_id $cmd="SELECT DISTINCT album_name, album_artist, album_id
FROM *PREFIX*media_albums INNER JOIN *PREFIX*media_songs ON album_id=song_album WHERE song_user=? "; FROM *PREFIX*media_albums INNER JOIN *PREFIX*media_songs ON album_id=song_album WHERE song_user=? ";
$params=array(self::$uid); $params=array(self::$uid);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment