Hi folks,
I would like to be able to pass a DB handle between pages on a web site so that I will be able to use the same db connection. The connection works fine as long as I use it within the same file but when I try to pass the handle to another page I get the following error message.
Can't locate object method "prepare" via package "DBI::db=HASH(0x831cef8)" (perhaps you forgot to load "DBI::db=HASH(0x831cef8)"?) at TransactionDB.pm line 43.
I created the TransactionDB.pm file mentioned in the error message and if works fine.
I use
my $dbh = param('dbh');
to get the handle, which I then pass to a method which works fine elsewhere in the program.
I read somewhere that the DB object gets converted to a string, thats why it does not recognise the object, but I do not know how to maintain the handle as an obect when passing it to another page.
Any thoughts?
Thanks
Cal
I would like to be able to pass a DB handle between pages on a web site so that I will be able to use the same db connection. The connection works fine as long as I use it within the same file but when I try to pass the handle to another page I get the following error message.
Can't locate object method "prepare" via package "DBI::db=HASH(0x831cef8)" (perhaps you forgot to load "DBI::db=HASH(0x831cef8)"?) at TransactionDB.pm line 43.
I created the TransactionDB.pm file mentioned in the error message and if works fine.
I use
my $dbh = param('dbh');
to get the handle, which I then pass to a method which works fine elsewhere in the program.
I read somewhere that the DB object gets converted to a string, thats why it does not recognise the object, but I do not know how to maintain the handle as an obect when passing it to another page.
Any thoughts?
Thanks
Cal