]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix searching artists and albums
authorRobin Appelman <icewind1991@gmail.com>
Thu, 12 Jan 2012 01:01:59 +0000 (02:01 +0100)
committerRobin Appelman <icewind1991@gmail.com>
Thu, 12 Jan 2012 01:01:59 +0000 (02:01 +0100)
apps/media/lib_collection.php

index ed8aebb63281ab6f297ec1942d1a1cc9ce6fec60..d8dda1212e4225f6b4aa69f093427d6ee55fcd07 100644 (file)
@@ -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);