|
| Hi ,
Urgent help.
I have written 2 modules one abc.pm & xyz.pm (admin modules).
abc.pm
--------------------------------------
my $databasehandle;
sub new($){
my ($self,$usr,$pwd) = @_;
$usr||= "test";
$pwd ||= "test123";
($self) = {};
bless($self);
$databasehandle = DBI->connect("DBI:Pg:dbname=mydb",$usr,$pwd,
{PrintError =>1});
if (!$databasehandle){
print "Database connection is not estabilished";
exit;
}
return($self);
}
sub DESTROY(){
my $self;
$self->disconnect();
}
sub disconnect(){
$databasehandle->disconnect() if ($databasehandle);
}
xyz.pm
----------
package admin;
use DBI;
use Apache::DBI;
use CGI;
use abc;
use strict;
my $database_handle =();
sub new()
{
my $self={};
bless($self);
$database_handle = abc->new('test','test123');
if (!$database_handle){
print "connection cant done:";
return -1;
}
print " connection done:";
return $self;
}
sub display()
{
my $self = shift;
my $sth = $database_handle->prepare("select * from table where status
='P'");
print $sth;
my $res =$sth->execute();
my @row = $sth->fetchrow_array();
print @row;
return $res;
}
I am getting an error :
Can't locate object method "prepare" via package "abc" at xyz.pm
Is it not possible the way i am trying...can anyone tell me where i am
wrong.
Thanks ,
Alma
|
|