From 87ef5e00189e7ac23af2c3d949e4a6d3550aa7d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 11 Aug 2016 13:22:20 +0200 Subject: [PATCH] CsvReport: single-dbh --- SL/DB/CsvImportReport.pm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/SL/DB/CsvImportReport.pm b/SL/DB/CsvImportReport.pm index b3cdf3bf3..b9c34eb34 100644 --- a/SL/DB/CsvImportReport.pm +++ b/SL/DB/CsvImportReport.pm @@ -4,6 +4,7 @@ package SL::DB::CsvImportReport; use strict; +use SL::DB; use SL::DBUtils; use SL::DB::MetaSetup::CsvImportReport; @@ -56,20 +57,19 @@ sub folded_status { sub destroy { my ($self) = @_; - my $dbh = $self->db->dbh; + SL::DB->client->with_transaction(sub { + my $dbh = SL::DB->client->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); - 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; + 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); + } + 1; + }) or do { die SL::DB->client->error }; } 1; -- 2.20.1