Ticket #3138: mythweb-music-optimize.patch

File mythweb-music-optimize.patch, 3.9 KB (added by otto at kolsi dot fi, 13 years ago)
  • modules/music/mp3act_functions.php

     
    6969
    7070function genreform()
    7171{
    72   $query = "SELECT * FROM music_genres ORDER BY genre";
     72  $query = "SELECT genre FROM music_genres ORDER BY genre";
    7373  $result = mysql_query($query);
    7474
    7575  if (!$result)
     
    300300        <strong>'.t('Album Listing').'</strong></p>
    301301        <ul class="music">';
    302302      $start = $itemid;
    303       $query  = 'SELECT ma.*,mt.artist_name '.
     303      $query  = 'SELECT ma.album_id, ma.album_name, mt.artist_name '.
    304304        'FROM music_albums AS ma '.
    305305        'LEFT JOIN music_artists AS mt ON ma.artist_id=mt.artist_id '.
    306306        'ORDER BY album_name, artist_name';
     
    335335      $length = $row[1];
    336336
    337337      // Attempt to find some album art.
    338       $query='SELECT * '.
    339         'FROM music_songs '.
    340         'WHERE album_id='.$sql_itemid.' '.
     338      $query='SELECT ms.filename, ms.album_id, md.path '.
     339        'FROM music_songs AS ms '.
     340        'LEFT JOIN music_directories AS md ON ms.directory_id=md.directory_id '.
     341        'WHERE ms.album_id='.$sql_itemid.' '.
    341342        'LIMIT 1;';
    342343      $result = mysql_query($query);
    343344      if (!$result)
     
    390391        <strong>'.t('Album Tracks').'</strong>
    391392        <ul class="music">';
    392393
    393       $query = 'SELECT music_songs.*, SEC_TO_TIME(music_songs.length/1000) AS length, artist_name '.
    394         'FROM music_songs '.
    395         'LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id '.
    396         'WHERE album_id='.$sql_itemid.' '.
    397         'ORDER BY track';
     394      $query = 'SELECT ms.song_id, ms.track, ms.name, ms.length, ms.numplays, '.
     395        'SEC_TO_TIME(ms.length/1000) AS length, artist_name '.
     396        'FROM music_songs AS ms '.
     397        'LEFT JOIN music_artists ON ms.artist_id=music_artists.artist_id '.
     398        'WHERE ms.album_id='.$sql_itemid.' '.
     399        'ORDER BY ms.track';
    398400      $result = mysql_query($query);
    399401      if (!$result)
    400402        break;
     
    415417        <p><strong>".t('Songs').'</strong></p>
    416418        <ul class="music">';
    417419
    418       $query = 'SELECT music_songs.*, music_artists.artist_name, music_genres.genre '.
    419         'FROM music_songs '.
    420         'LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id '.
    421         'LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id '.
    422         'WHERE genre='.$sql_itemid.';';
     420      $query = 'SELECT ms.song_id, ms.name, ms.length, ms.numplays, '.
     421        'music_artists.artist_name, music_genres.genre '.
     422        'FROM music_songs AS ms '.
     423        'LEFT JOIN music_artists ON ms.artist_id=music_artists.artist_id '.
     424        'LEFT JOIN music_genres ON ms.genre_id=music_genres.genre_id '.
     425        'WHERE genre='.utf8_encode($sql_itemid).';';
    423426
    424427      $result = mysql_query($query);
    425428      if (!$result)
     
    452455        <p><strong>'.t('Songs').'</strong></p>
    453456        <ul class="music">';
    454457
    455       $query = 'SELECT music_songs.*, SEC_TO_TIME(music_songs.length/1000) AS length, music_artists.artist_name, track, music_albums.album_name '.
    456         'FROM music_songs '.
    457         'LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id '.
    458         'LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id '.
    459         'WHERE music_songs.artist_id='.$sql_itemid.';';
     458      $query = 'SELECT ms.song_id, ms.track, ms.name, ms.length, ms.numplays, '.
     459        'SEC_TO_TIME(ms.length/1000) AS length, music_artists.artist_name, track, music_albums.album_name '.
     460        'FROM music_songs AS ms '.
     461        'LEFT JOIN music_artists ON ms.artist_id=music_artists.artist_id '.
     462        'LEFT JOIN music_albums ON ms.album_id=music_albums.album_id '.
     463        'WHERE ms.artist_id='.$sql_itemid.';';
    460464      $result = mysql_query($query);
    461465      if (!$result)
    462466        break;