X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/576c2a14f72af8f2cfe5679b6c264f13aff39ddf..ffa9f969259970df45ea2353a94d1a67e8612731:/SL/DBConnect.pm diff --git a/SL/DBConnect.pm b/SL/DBConnect.pm index afdf2c9e1..369cfe158 100644 --- a/SL/DBConnect.pm +++ b/SL/DBConnect.pm @@ -4,6 +4,7 @@ use strict; use DBI; use SL::DB; +use SL::DBConnect::Cache; my %dateformat_to_datestyle = ( 'yy-mm-dd' => 'ISO', @@ -33,18 +34,24 @@ sub _connect { sub connect { my ($self, @args) = @_; + if (my $cached_dbh = SL::DBConnect::Cache->get(@args)) { + 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); + return $dbh; } sub get_datestyle { my ($self, $dateformat) = @_; - return $dateformat_to_datestyle{ $dateformat || $::myconfig{dateformat} }; + return $dateformat_to_datestyle{ $dateformat || $::myconfig{dateformat} // '' }; } sub get_initial_sql { @@ -72,7 +79,7 @@ sub get_connect_args { sub get_options { my $self = shift; my $options = { - pg_enable_utf8 => $::locale->is_utf8, + pg_enable_utf8 => 1, @_ };