I know this will sound incredibly stupid and n00bish, but I've encountered something I've never dealt with before. I'm setting up a perl based web application (this is my first web app, not my first perl) and have an issue with multiple DBI calls in a page and how I handle those calls. For the most part, I've keep my code over the years to one DBI handle per script, so this is new to me.

If I have code like this:

    my $dbh = DBI->connect(config('data_source'), config('username'), 
config('password'));
    my $dao = EmbMon::DAO->new($dbh);
    my $sql = qq/SELECT abbreviation from factory/;
    my $sth = $dbh->prepare($sql);
    $sth->execute();

and I want to run another query to the same DB, can I do something like:

my $sql = qq/Select * from table/;
my $sth = $dbh->prepare($sql);
$sth->execute();

Or do I need to call DBI->connect again? I've curious as to how this is handled, since I don't see a close() or disconnect() used in any of the existing, inherited, code, which I normally use just to clean up after the script runs.

What's the best way to do this?

--

Mark Haney
Software Developer/Consultant
AB Emblem
ma...@abemblem.com
Linux marius.homelinux 3.3.5-2.fc16.x86_64 GNU/Linux

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to