Re: Using DBI
[prev]
[thread]
[next]
[Date index for 2004/12/28]
On Tue, 28 Dec 2004, Randy Kobes wrote:
[ ... ]
> Can you try the
> following patch against Apache::DBI (version 0.94) - if
> you're using ppm on Win32, you can get this from the
> Apache-DBI.ppd package in the
> http://theoryx5.uwinnipeg.ca/ppms/
> repository.
Sorry about this - I missed one thing. Can you try the
following instead:
=============================================================
--- DBI.pm~ Tue Feb 17 18:18:50 2004
+++ DBI.pm Tue Dec 28 17:17:18 2004
@@ -13,7 +13,7 @@
# 1: report about new connect
# 2: full debug output
-$Apache::DBI::DEBUG = 0;
+$Apache::DBI::DEBUG = 2;
#DBI->trace(2);
my %Connected; # cache for database handles
@@ -23,6 +23,8 @@
my %LastPingTime; # keeps track of last ping per data_source
my $Idx; # key of %Connected and %Rollback.
+use Apache::ServerUtil ();
+my $s = Apache->server;
# supposed to be called in a startup script.
# stores the data_source of all connections, which are supposed to be created upon
@@ -32,9 +34,8 @@
# provide a handler which creates all connections during server startup
# TODO - Should check for mod_perl 2 and do the right thing there
- carp "Apache.pm was not loaded\n" and return unless $INC{'Apache.pm'};
- if(!@ChildConnect and Apache->can('push_handlers')) {
- Apache->push_handlers(PerlChildInitHandler => \&childinit);
+ if(!@ChildConnect) {
+ $s->push_handlers(PerlChildInitHandler => \&childinit);
}
# store connections
push @ChildConnect, [@_];
@@ -94,9 +95,9 @@
# this PerlCleanupHandler is supposed to initiate a rollback after the script has finished if AutoCommit is off.
my $needCleanup = ($Idx =~ /AutoCommit[^\d]+0/) ? 1 : 0;
# TODO - Fix mod_perl 2.0 here
- if(!$Rollback{$Idx} and $needCleanup and Apache->can('push_handlers')) {
+ if(!$Rollback{$Idx} and $needCleanup) {
print STDERR "$prefix push PerlCleanupHandler \n" if $Apache::DBI::DEBUG > 1;
- Apache->push_handlers("PerlCleanupHandler", \&cleanup);
+ $s->push_handlers("PerlCleanupHandler", \&cleanup);
# make sure, that the rollback is called only once for every
# request, even if the script calls connect more than once
$Rollback{$Idx} = 1;
==============================================================================
--
best regards,
randy
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
 |
Using DBI
Octavian Rasnita 19:21 on 28 Dec 2004
|