From a84085ef13935425d9d2552ae5c457dc8bd4471e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 8 Sep 2016 16:50:16 +0200 Subject: [PATCH] Form: single-dbh disconnects --- SL/Form.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 60b3c9af8..5c7d062ab 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1535,18 +1535,18 @@ sub save_exchangerate { my ($self, $myconfig, $currency, $transdate, $rate, $fld) = @_; - my $dbh = $self->dbconnect($myconfig); - - my ($buy, $sell); - - $buy = $rate if $fld eq 'buy'; - $sell = $rate if $fld eq 'sell'; + SL::DB->client->with_transaction(sub { + my $dbh = SL::DB->client->dbh; + my ($buy, $sell); - $self->update_exchangerate($dbh, $currency, $transdate, $buy, $sell); + $buy = $rate if $fld eq 'buy'; + $sell = $rate if $fld eq 'sell'; - $dbh->disconnect; + $self->update_exchangerate($dbh, $currency, $transdate, $buy, $sell); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } -- 2.20.1