perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Perrin Harkins <per...@elem.com>
Subject Re: Using Apache::DBI
Date Mon, 08 May 2006 13:26:40 GMT
Octavian Rasnita wrote:
> I thought the best way of using Apache::DBI is to put the following code in
> the startup.pl script:
> 
> use Apache::DBI ();
> Apache::DBI->connect_on_init('DBI:mysql:database=database_name;host=10.50.28
> .37', 'user', undef, {PrintError => 1, RaiseError => 0, AutoCommit => 1});
> use DBI ();
> 
> But I understand that it is better to disconnect from the database after the
> server starts or to connect to the database only after the server starts.

What you're doing is correct.  The connect_on_init() method doesn't 
connect until the PerlInitHandler phase, which is when a new child 
starts up.  Even if you just call DBI->connect during startup, 
Apache::DBI will not cache connections until after the server starts.

- Perrin

Mime
View raw message