diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-01-17 14:25:12 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-01-17 14:25:12 +0000 |
commit | 9f87707043594ec990e1c96fe806c93869387c8d (patch) | |
tree | 5762b9f07c7c10f7bec49585cd4afb347bc7f7cd /lib | |
parent | 66ff3d58dfe8d601acbc0e70c095e6f59a3512ad (diff) | |
download | ampache-9f87707043594ec990e1c96fe806c93869387c8d.tar.gz ampache-9f87707043594ec990e1c96fe806c93869387c8d.tar.bz2 ampache-9f87707043594ec990e1c96fe806c93869387c8d.zip |
fixed a clean issue with rated items
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/catalog.class.php | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index bbb6c329..1f4f308b 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1358,7 +1358,7 @@ class Catalog { function clean_flagged() { /* Do a complex delete to get flagged items where the songs are now gone */ - $sql = "DELETE FROM flagged USING flagged LEFT JOIN song ON song.id = flagged.song WHERE song.id IS NULL"; + $sql = "DELETE FROM flagged USING flagged LEFT JOIN song ON song.id = flagged.object_id WHERE song.id IS NULL AND object_type='song'"; $db_results = mysql_query($sql, dbh()); } // clean_flagged @@ -1435,6 +1435,22 @@ class Catalog { $sql = "DELETE FROM object_count USING object_count LEFT JOIN live_stream ON live_stream.id=object_count.object_id WHERE object_type='live_stream' AND live_stream.id IS NULL"; $db_results = mysql_query($sql,dbh()); + // Delete Song Ratings information + $sql = "DELETE FROM ratings USING ratings LEFT JOIN song ON song.id=ratings.object_id WHERE object_type='song' AND song.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + + // Delete Genre Ratings Information + $sql = "DELETE FROM ratings USING ratings LEFT JOIN genre ON genre.id=ratings.object_id WHERE object_type='genre' AND genre.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + + // Delete Album Rating Information + $sql = "DELETE FROM ratings USING ratings LEFT JOIN album ON album.id=ratings.object_id WHERE object_type='album' AND album.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + + // Delete Artist Rating Information + $sql = "DELETE FROM ratings USING ratings LEFT JOIN artist ON artist.id=ratings.object_id WHERE object_type='artist' AND artist.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + } // clean_stats /*! @@ -2125,24 +2141,6 @@ class Catalog { */ function delete_catalog() { - // Do some crazyness to delete all the songs in this catalog - // from playlists... - $sql = "SELECT playlist_data.song FROM song,playlist_data,catalog WHERE catalog.id=song.catalog AND playlist_data.song=song.id AND catalog.id='$this->id'"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_object($db_results)) { - $results[] = $r; - } - - foreach ($results as $r) { - // Clear Playlist Data - $sql = "DELETE FROM playlist_data WHERE song='$r->song'"; - $db_results = mysql_query($sql, dbh()); - - } // End Foreach - // First remove the songs in this catalog $sql = "DELETE FROM song WHERE catalog = '$this->id'"; $db_results = mysql_query($sql, dbh()); @@ -2155,8 +2153,8 @@ class Catalog { $this->clean_albums(); $this->clean_artists(); $this->clean_playlists(); - $this->clean_flagged(); $this->clean_genres(); + $this->clean_flagged(); $this->clean_stats(); $this->clean_ext_info(); |