Kelvin Wu wrote:
1. Do I still need to use 'use Apache::DBI;' in my script (or in
startup.pl) if I already set 'PerlModule Apache::DBI' in httpd.conf?
you should _never_ use Apache::DBI in your script itself.
1)
httpd.conf
<Perl>
use Aapche::DBI ();
</Perl>
2) httpd.conf
PerlModule Apache::DBI
3) startup.pl
use Apache::DBI ();
Are all equivalent
2. Will Apache::DBI work (caches and manages connections etc) if I dont
change my CGI script DB calls but simply adding one line "use Apache::DBI"?
Yes.
3. How to limit DB connections from script? Or number of
connections simply equals to number of HTTPd?
in prefork mpm, you'll need at least 1 $dbh perl httpd child process
Theres nothing stopping your from opening more though (aka 2 different
dbs 1 each)
4. By setting $Apache::DBI::DEBUG = 2; Where output goes to?
STDERR aka error_log
5. How many DB connections will be established by using
Apache::DBI->connect_on_init()?
This doesn't change the number of connects, this just sets it so that
when httpd children are spawned we add a PerlInitChildHandler() that
create/connects the $dbh for this child. Without this, the _first_
request per child will have to actually connect to the db and _then_
it will be managed by Apache::DBI.
6. If I use Apache::DBI->connect_on_init() in startup.pl, will it take
care of DBI->connect() in my script? eg, DBI->connect() wont actually
create a new connection.
connect_on_init() has no effect on the script. DBI knows about
Apache::DBI and if Apache::DBI is loaded (correctly) will forward all
calls to DBI::connect() -> Apache::DBI::connect()
7. If I do NOT use Apache::DBI->connect_on_init() in startup.pl, will
Apache::DBI still manage DBI->connect() in my script? eg, wont actually
create a new connection if there is a free connection created by
ex-DBI->connect() call.
Ditto #6.
8. Will $dbh->disconnect() simply be ignored by using Apache::DBI or, it
will kill DB connection?
Apache::DBI overrides DBI::disconnect. You should not change your
current $dbh->disconnect() calls.
# overload disconnect
{
package Apache::DBI::db;
no strict;
@ISA=qw(DBI::db);
use strict;
sub disconnect {
my $prefix = "$$ Apache::DBI ";
Apache::DBI::debug(2, "$prefix disconnect (overloaded)");
1;
}
;
}
Notice all it does it write to the log.
--
------------------------------------------------------------------------
Philip M. Gollucci ([EMAIL PROTECTED]) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/EC88A0BF 0DE5 C55C 6BF3 B235 2DAB B89E 1324 9B4F EC88 A0BF
Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.