]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DBConnect.pm
Banktransactions - beim Speichern der Rechnung Zahlungsart prüfen
[mfinanz.git] / SL / DBConnect.pm
index 7d3ea41088e086407c934f3ae03b1ba7ca210ef4..369cfe15889c16a8dc5b2d7ef2f126bd84c8c565 100644 (file)
@@ -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 {