From 5d74fd02daea21f5802cb4b5089408dd3bcc2031 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 7 Nov 2012 13:43:35 +0100 Subject: [PATCH] =?utf8?q?destroy=20methode=20f=C3=BCr=20CsvImportReport?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/CsvImportReport.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/SL/DB/CsvImportReport.pm b/SL/DB/CsvImportReport.pm index 38d9e697e..1271c56ae 100644 --- a/SL/DB/CsvImportReport.pm +++ b/SL/DB/CsvImportReport.pm @@ -4,6 +4,7 @@ package SL::DB::CsvImportReport; use strict; +use SL::DBUtils; use SL::DB::MetaSetup::CsvImportReport; @@ -63,4 +64,24 @@ sub _fold_status { } } +# implementes cascade delete as per documentation +sub destroy { + my ($self) = @_; + + my $dbh = $self->db->dbh; + + $dbh->begin_work; + + do_query($::form, $dbh, 'DELETE FROM csv_import_report_status WHERE csv_import_report_id = ?', $self->id); + do_query($::form, $dbh, 'DELETE FROM csv_import_report_rows WHERE csv_import_report_id = ?', $self->id); + do_query($::form, $dbh, 'DELETE FROM csv_import_reports WHERE id = ?', $self->id); + + if ($self->profile_id) { + do_query($::form, $dbh, 'DELETE FROM csv_import_profile_settings WHERE csv_import_profile_id = ?', $self->profile_id); + do_query($::form, $dbh, 'DELETE FROM csv_import_profiles WHERE id = ?', $self->profile_id); + } + + $dbh->commit; +} + 1; -- 2.20.1