Skip to content
Snippets Groups Projects
Commit ab684773 authored by Web Admin's avatar Web Admin
Browse files

changed connect to reset connected to 0 rather than set it up at the right time

parent b6c606aa
No related branches found
No related tags found
No related merge requests found
...@@ -179,6 +179,7 @@ sub connect { ...@@ -179,6 +179,7 @@ sub connect {
my $self = shift; my $self = shift;
return if($self->connected); return if($self->connected);
$self->connected(1);
if(defined($self->db_handle()) and $self->db_handle()->ping()) { if(defined($self->db_handle()) and $self->db_handle()->ping()) {
warning("unconnected db_handle is still pingable, reseting connected boolean\n"); warning("unconnected db_handle is still pingable, reseting connected boolean\n");
...@@ -196,12 +197,12 @@ sub connect { ...@@ -196,12 +197,12 @@ sub connect {
warn("Could not connect to database " . $self->dbname() . warn("Could not connect to database " . $self->dbname() .
" as user " . $self->username() . " as user " . $self->username() .
" using [$dsn] as a locator:\n" . $DBI::errstr); " using [$dsn] as a locator:\n" . $DBI::errstr);
$self->connected(0);
throw("Could not connect to database " . $self->dbname() . throw("Could not connect to database " . $self->dbname() .
" as user " . $self->username() . " as user " . $self->username() .
" using [$dsn] as a locator:\n" . $DBI::errstr); " using [$dsn] as a locator:\n" . $DBI::errstr);
} }
$self->connected(1);
$self->db_handle($dbh); $self->db_handle($dbh);
#print("CONNECT\n"); #print("CONNECT\n");
} }
...@@ -513,7 +514,7 @@ sub db_handle { ...@@ -513,7 +514,7 @@ sub db_handle {
return $self->{'db_handle'.$$} = shift if(@_); return $self->{'db_handle'.$$} = shift if(@_);
return $self->{'db_handle'.$$} if($self->connected); return $self->{'db_handle'.$$} if($self->connected);
# $self->connect(); $self->connect();
return $self->{'db_handle'.$$}; return $self->{'db_handle'.$$};
} }
...@@ -541,7 +542,6 @@ sub prepare { ...@@ -541,7 +542,6 @@ sub prepare {
# print STDERR "SQL(".$self->dbname."):$string\n"; # print STDERR "SQL(".$self->dbname."):$string\n";
$self->connect() unless $self->connected();
my $sth = $self->db_handle->prepare($string); my $sth = $self->db_handle->prepare($string);
# return an overridden statement handle that provides us with # return an overridden statement handle that provides us with
...@@ -576,7 +576,6 @@ sub do { ...@@ -576,7 +576,6 @@ sub do {
#info("SQL(".$self->dbname."):$string"); #info("SQL(".$self->dbname."):$string");
$self->connect() unless $self->connected();
my $result = $self->db_handle->do($string); my $result = $self->db_handle->do($string);
# disconnect if the disconnect when inactive flag is set and # disconnect if the disconnect when inactive flag is set and
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment