On Wed, 1 Aug 2001, Philip Mak wrote:

> I have a CGI application where I do:
> 
> require 'db.pl';
> 
> where db.pl defines some functions and variables related to connecting to
> the database, and then executes C<$dbh = DBI->connect(...)>.
> 
> I tried to convert this application to modperl, but I ran into the problem
> that require did not execute db.pl again the second time I called the
> script, so that the C<$dbh = DBI->connect(...)> line was not executed.
> 
> I can get around this by changing C<require> to C<do>, but is that the
> "correct" way of doing things? It seems a waste to redefine all the
> subroutines and variables again. But I do need it to reinitialize $dbh
> when C<require 'db.pl';> is called.
> 
> What should I do?


One of the things you should do that I have not yet seen mentioned is
look into using Apache::DBI so you don't have it "reinitialize $dbh" on
every request. 

If you do have multiple DBs in your application you can still used cached
database handles; just name them differently.

- nick

Reply via email to