in reply to Re: One module for both Apache::DBI and DBI?
in thread One module for both Apache::DBI and DBI?

Thank tedrek. What you said are correct. (And PerlModule Apache::DBI is in fact how I did it.)

Maybe my question should have been something more general, like how to dynamically select which modules to use, if possible.

Like, a regular DB module could probably be used under Apache as well, except that it would not need "use Apache::Reload", although it won't do anything harm if I redundantly include it.

So, dynamically determining which modules to use at runtime is out of the question?

Thanks.
  • Comment on Re: Re: One module for both Apache::DBI and DBI?

Replies are listed 'Best First'.
(jeffa) 3Re: One module for both Apache::DBI and DBI?
by jeffa (Bishop) on Jun 01, 2003 at 01:43 UTC

    "... a regular DB module could probably be used under Apache as well ..."

    A regular DB module? Are you wanting to create another database handle, in addition to the persistent ones provided by Apache::DBI? One that is not persistent?

    If so then check out recipe 2.13 from the mod_perl Developer's Cookbook. The idea is to use the optional %attr parameter in DBI->connect to allow uncached connections to be created - set dbi_connect_method to the value connect:
    my $dbh = DBI->connect( 'dbi:AnyData:', {dbi_connect_method => 'connect'}, );
    This will not affect the previously cached connections.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: Re: Re: One module for both Apache::DBI and DBI?
by tedrek (Pilgrim) on Jun 01, 2003 at 00:14 UTC

    Yes you can use one of the other DB modules instead of DBI.

    Apache::Reload is for when you are developing a module and don't want to restart apache everytime you make a change to your module, or when the module's on the server get updated very often.

    It is possible to dynamically select a module to use however you don't need to very often. and you probably don't need to in this case. That being said:

    #Dynamically choose betten Foo and Bar my $type = 'foo'; if ($type eq 'foo') { eval "use Foo"; } else { eval "use Bar"; }

    note that you have to use a quoted string for the eval rather than a block. if you use a block it will always 'use' that module.