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