package ADB; use DBI; @ISA = ('Exporter'); @EXPORT_OK = ("Connection_check", "new","select_db"); sub new { my $class = shift; my $self = { _pf => shift, _db => shift, _host => shift, _port => shift, _user => shift, _pass => shift }; $dbh = Connection_check($self); #$self->{_dbh} = $dbh; bless $self, $class; return $self; } sub Connection_check { my($self ) = @_; $dsn = "DBI:$self->{_pf}:$self->{_db};$self->{_host};$self->{_port}"; #$dsn = "DBI:mysql:database=$self->{_db};host=$self->{_host};port=$self->{_port}"; $dbhc = DBI->connect($dsn,$self->{_user},$self->{_pass})or die "Unable to connect: $DBI::errstr\n"; return ($dbhc) } ### Retrieving the Rows ######## sub select_db{ my ($obj,$sel) = @_; my $selnew = $dbh->prepare($sel); $selnew->execute or die "Unable to connect: $DBI::errstr\n"; my @AoA; my @FinArr; while (@AoA = $selnew->fetchrow_array) { push @FinArr, [@AoA]; } return @FinArr; }