[mb-commits] r9996 - in mb_server/branches/Discographies-BRANCH: admin/sql/updates cgi-bin/MusicBrainz/Server
root at musicbrainz.org
root at musicbrainz.org
Thu Jul 10 19:54:13 UTC 2008
Author: niklas
Date: 2008-07-10 19:54:13 +0000 (Thu, 10 Jul 2008)
New Revision: 9996
Added:
mb_server/branches/Discographies-BRANCH/admin/sql/updates/discography.sql
Modified:
mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm
Log:
added update script
Added: mb_server/branches/Discographies-BRANCH/admin/sql/updates/discography.sql
Modified: mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm
===================================================================
--- mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm 2008-07-10 16:05:46 UTC (rev 9995)
+++ mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm 2008-07-10 19:54:13 UTC (rev 9996)
@@ -195,23 +195,47 @@
# make sure this is valid format for a mbid
if($mbid =~ m/[a-z0-9]{8}[:-][a-z0-9]{4}[:-][a-z0-9]{4}[:-][a-z0-9]{4}[:-][a-z0-9]{12}/)
{
- my $sql=$this->{DBH};
+ my $rawsql = $this->{RAWDBH};
+ my $rosql = $this->{RODBH};
+
print "\nremoving $mbid\n";
+
+ # get id for realease with specified mbid
+ my $albumId;
+
eval
{
- $sql->Begin();
+ $rosql->Begin();
+
+ my $idQuery = "SELECT id FROM album WHERE gid='$mbid'";
+ $albumId = $rosql->SelectSingleValue($idQuery);
+ };
+
+ if($@)
+ {
+ print $@;
+ $rosql->Commit();
+ }
+ else
+ {
+ $rosql->Commit();
+ }
+
+ eval
+ {
+ $rawsql->Begin();
# get the album id
#my $selectResult=$sql->SelectSingleRowHash("SELECT id FROM album WHERE gid='$mbid'");
#my $albumId=$selectResult->{id};
# make sure there is a release with the mbid in the database
- my $deleteResult=$sql->Do("DELETE FROM collection_has_release_join WHERE album=(SELECT id FROM album WHERE gid='$mbid')");
+ my $deleteResult = $rawsql->Do("DELETE FROM collection_has_release_join WHERE album='$albumId' AND collection_info='". $this->{collectionId} ."'");
print "Result:$deleteResult\n";
- if($deleteResult==1) # successfully deleted
+ if($deleteResult == 1) # successfully deleted
{
# increase remove count
$this->{removeAlbum_removeCount}++;
@@ -220,7 +244,7 @@
if($@)
{
- my $error=$@; # get the error message
+ my $error = $@; # get the error message
print $error;
$sql->Commit();
}
More information about the MusicBrainz-commits
mailing list