From: Robin Appelman Date: Thu, 12 Jan 2012 01:01:59 +0000 (+0100) Subject: fix searching artists and albums X-Git-Tag: v3.0~60^2~9^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8de4163ba234a2eca124e2f389e9d4c999f06c00;p=nextcloud-server.git fix searching artists and albums --- diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index ed8aebb6328..d8dda1212e4 100644 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -121,14 +121,19 @@ class OC_MEDIA_COLLECTION{ * @return array the list of artists found */ static public function getArtists($search='%',$exact=false){ + $uid=self::$uid; + if(empty($uid)){ + $uid=self::$uid=$_SESSION['user_id']; + } if(!$exact and $search!='%'){ $search="%$search%"; }elseif($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 - 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"); - return $query->execute(array($search,self::$uid))->fetchAll(); + $query=OC_DB::prepare("SELECT DISTINCT artist_name, artist_id FROM *PREFIX*media_artists + INNER JOIN *PREFIX*media_songs ON artist_id=song_artist WHERE artist_name LIKE ? AND song_user=? ORDER BY artist_name"); + $result=$query->execute(array($search,self::$uid)); + return $result->fetchAll(); } /** @@ -159,6 +164,10 @@ class OC_MEDIA_COLLECTION{ * @return array the list of albums found */ 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 FROM *PREFIX*media_albums INNER JOIN *PREFIX*media_songs ON album_id=song_album WHERE song_user=? "; $params=array(self::$uid);