ported 257:258 from hidra branch
[webpac] / index_DBI.pm
index f4a5153..c366976 100644 (file)
@@ -17,8 +17,12 @@ sub new {
        my $self = {};
        bless($self, $class);
 
-       # FIX: config params
-       $self->{dbh} = DBI->connect("DBI:Pg:dbname=webpac","dpavlin","") || die $DBI::errstr;
+       my $dbd = shift || die "need dbi_dbd= in [global] section of configuration file";
+       my $dsn = shift || die "need dbi_dsn= in [global] section of configuration file";
+       my $user = shift || die "need dbi_user= in [global] section of configuration file";
+       my $passwd = shift || die "need dbi_passwd= in [global] section of configuration file";
+
+       $self->{dbh} = DBI->connect("DBI:$dbd:$dsn",$user,$passwd) || die $DBI::errstr;
        # begin transaction
        $self->{dbh}->begin_work || die $self->{dbh}->errstr();
 
@@ -181,6 +185,9 @@ sub close {
 # FIX
 print STDERR "creating ord for $table...\n";
                        create_ord($table);
+                       undef $sth_cache{$table."select"};
+                       undef $sth_cache{$table."insert"};
+                       undef $sth_cache{$table."update"};
                }
 
                $self->{dbh}->disconnect;