From: Sven Schöling Date: Wed, 7 Nov 2012 12:43:35 +0000 (+0100) Subject: destroy methode für CsvImportReport X-Git-Tag: release-3.1.0beta1~743 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5d74fd02daea21f5802cb4b5089408dd3bcc2031;p=kivitendo-erp.git destroy methode für CsvImportReport --- 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;