fixed: More permissive DSN checking to allow use of SQLite (thanks pathma)
This commit is contained in:
parent
a48827553c
commit
46f6104d43
3 changed files with 15 additions and 10 deletions
|
|
@ -20,6 +20,7 @@ use Tie::CPHash;
|
|||
use WebGUI::SQL;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Utility;
|
||||
use DBI;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -238,16 +239,19 @@ sub db {
|
|||
if ($self->getId eq "0") {
|
||||
$self->{_dbh} = $self->session->db;
|
||||
return $self->{_dbh};
|
||||
} elsif ($dsn =~ /\DBI\:\w+\:\w+/i) {
|
||||
my $dbh = WebGUI::SQL->connect($self->session,$dsn,$username,$identifier,$parameters);
|
||||
unless (defined $dbh) {
|
||||
$self->session->errorHandler->warn("Cannot connect to DatabaseLink [".$self->getId."]");
|
||||
}
|
||||
$self->{_dbh} = $dbh;
|
||||
return $self->{_dbh};
|
||||
} else {
|
||||
$self->session->errorHandler->warn("DatabaseLink [".$self->getId."] The DSN specified is of an improper format.");
|
||||
}
|
||||
else {
|
||||
my ($scheme, $driver, $attr_string, $attr_hash, $driver_dsn) = DBI->parse_dsn($dsn);
|
||||
if ($driver) {
|
||||
my $dbh = WebGUI::SQL->connect($self->session,$dsn,$username,$identifier,$parameters);
|
||||
unless (defined $dbh) {
|
||||
$self->session->errorHandler->warn("Cannot connect to DatabaseLink [".$self->getId."]");
|
||||
}
|
||||
$self->{_dbh} = $dbh;
|
||||
return $self->{_dbh};
|
||||
}
|
||||
}
|
||||
$self->session->errorHandler->warn("DatabaseLink [".$self->getId."] The DSN specified is of an improper format.");
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ sub _setDataByQuery {
|
|||
$sth = $dbh->read($sql,$placeholders);
|
||||
}
|
||||
my $defaultPageNumber = $self->getPageNumber;
|
||||
$self->{_totalRows} = $sth->rows;
|
||||
$self->{_columnNames} = [ $sth->getColumnNames ];
|
||||
my $pageCount = 1;
|
||||
while (my $data = $sth->hashRef) {
|
||||
|
|
@ -125,6 +124,7 @@ sub _setDataByQuery {
|
|||
}
|
||||
}
|
||||
}
|
||||
$self->{_totalRows} = $sth->rows;
|
||||
$sth->finish;
|
||||
$self->{_rowRef} = \@row;
|
||||
#Purposely do not set $self->{_setByQuery} = 1 so the data is processed appropriately
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue