X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDBConnect.pm;h=9f2472c136b44b9d931d964ee694a309b316d960;hb=7ccc2fd5f71317fec080989578672a6fba2d7521;hp=369cfe15889c16a8dc5b2d7ef2f126bd84c8c565;hpb=ffa9f969259970df45ea2353a94d1a67e8612731;p=kivitendo-erp.git diff --git a/SL/DBConnect.pm b/SL/DBConnect.pm index 369cfe158..9f2472c13 100644 --- a/SL/DBConnect.pm +++ b/SL/DBConnect.pm @@ -16,7 +16,6 @@ my %dateformat_to_datestyle = ( sub _connect { my ($self, @args) = @_; - @args = $self->get_connect_args if !@args; return DBI->connect(@args) unless $::lx_office_conf{debug} && $::lx_office_conf{debug}->{dbix_log4perl}; @@ -33,18 +32,21 @@ sub _connect { sub connect { my ($self, @args) = @_; + @args = $self->get_connect_args if !@args; + my $initial_sql = $self->get_initial_sql; - if (my $cached_dbh = SL::DBConnect::Cache->get(@args)) { + if (my $cached_dbh = SL::DBConnect::Cache->get(@args, $initial_sql)) { return $cached_dbh; } my $dbh = $self->_connect(@args); return undef if !$dbh; - my $initial_sql = $self->get_initial_sql; - $dbh->do($initial_sql) if $initial_sql; - - SL::DBConnect::Cache->store($dbh, @args); + if ($initial_sql) { + $dbh->do($initial_sql); + $dbh->commit if !$dbh->{AutoCommit}; + } + SL::DBConnect::Cache->store($dbh, @args, $initial_sql); return $dbh; }