You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Georg Botorog <ge...@huggle.de> on 2003/03/11 17:47:31 UTC

[mp2] Using DBI instead of Apache::DBI

> Hello,
> 
> In mod_perl1, using persistent (Apache::DBI) and dedicated, per-user
> connections (DBI) on the same machine required running two Apache
> instances, one with Apache::DBI and the other without it.
> 
> Has anything about that changed in mod_perl2?
> 
> Moreover, how does Apache2 know it has to load Apache::DBI? There is
> no "PerlModule Apache::DBI" statement in my httpd.conf (as it was
> under mp1), neither a "use Apache::DBI" in startup.pl or in any other
> module. Or, to put it the other way around: how can I avoid including
> Apache::DBI (in the DBI-only instance)?
> 
> Thanks
> George
> 

Re: [mp2] Using DBI instead of Apache::DBI

Posted by Stas Bekman <st...@stason.org>.
Georg Botorog wrote:
>>Hello,
>>
>>In mod_perl1, using persistent (Apache::DBI) and dedicated, per-user
>>connections (DBI) on the same machine required running two Apache
>>instances, one with Apache::DBI and the other without it.
>>
>>Has anything about that changed in mod_perl2?
>>
>>Moreover, how does Apache2 know it has to load Apache::DBI? There is
>>no "PerlModule Apache::DBI" statement in my httpd.conf (as it was
>>under mp1), neither a "use Apache::DBI" in startup.pl or in any other
>>module. Or, to put it the other way around: how can I avoid including
>>Apache::DBI (in the DBI-only instance)?

As you said Apache::DBI is either on or off and it will work just the same 
under mp2 as it does under mp1.

However in the near future DBI is going to support pooling internally, which 
will take the benefit of threads if available.

And I think it could be made more flexible than Apache::DBI, i.e. too be more 
than just on or off. I think Apache::DBI can do the same. What we really need 
is some sort of pragma where you can control Apache::DBI. e.g. let's say that 
once you load Apache::DBI it turns the pooling on globally. But than in your 
script you should be able to say (you can't do it just yet):

no Apache::DBI; # which calls Apache::DBI::unimport
$dbh = DBI->connect(...)

and the unimport will restore the default DBI behavior for the scope of that 
pragma (e.g. handler) and restores to the previous behavior on the scope exit. 
Similar to how the warnings pragma works.

It's be nice to have a generic pragma for turning any functionality on and off 
(do we have one already?). e.g. let's call it 'override':

use override 'Apache::DBI';
# Apache::DBI overrides DBI here
no override 'Apache::DBI';
# the previous functionality is restored (e.g. back to DBI)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com