… | |
… | |
73 | my ($id, $dsn, $user, $pass, $flags, $connect) = @_; |
73 | my ($id, $dsn, $user, $pass, $flags, $connect) = @_; |
74 | # the following line is duplicated in PApp::SQL::Database::new |
74 | # the following line is duplicated in PApp::SQL::Database::new |
75 | $id = "$id\0$dsn\0$user\0$pass"; |
75 | $id = "$id\0$dsn\0$user\0$pass"; |
76 | unless ($dbcache{$id} && $dbcache{$id}->ping) { |
76 | unless ($dbcache{$id} && $dbcache{$id}->ping) { |
77 | #warn "connecting to ($dsn|$user|$pass|$flags)\n";#d# |
77 | #warn "connecting to ($dsn|$user|$pass|$flags)\n";#d# |
78 | # first, nuke our cache (sooory ;) |
78 | # first, nuke our statement cache (sooory ;) |
79 | cachesize cachesize 0; |
79 | cachesize cachesize 0; |
80 | # then connect anew |
80 | # then connect anew |
81 | $dbcache{$id} = |
81 | $dbcache{$id} = |
82 | eval { DBI->connect($dsn, $user, $pass, $flags) } |
82 | eval { DBI->connect($dsn, $user, $pass, $flags) } |
83 | || eval { DBI->connect($dsn, $user, $pass, $flags) } |
83 | || eval { DBI->connect($dsn, $user, $pass, $flags) } |
84 | || die "$DBI::errstr\n"; |
84 | || die "unable to connect to database $dsn: $DBI::errstr\n"; |
85 | $connect->($dbcache{$id}) if $connect; |
85 | $connect->($dbcache{$id}) if $connect; |
86 | } |
86 | } |
87 | $dbcache{$id}; |
87 | $dbcache{$id}; |
88 | } |
88 | } |
89 | |
89 | |