Apache::DBI is completely transparent if you get DBI right in the first
place (for better or worse ;) - no need to 'use vars' or anything.
just put
PerlModule Apache::DBI in httpd.conf or
use Apache::DBI in startup.pl
and make sure it occurs before you load DBI (via PerlModule or use)
see
http://perl.apache.org/guide/databases.html#Apache_DBI_Initiate_a_persist
and the man pages for more :)
--Geoff
> -----Original Message-----
> From: James G Smith [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 29, 2000 1:56 PM
> To: James Array
> Cc: [EMAIL PROTECTED]
> Subject: Re: porting DBI to Apache::DBI
>
>
> "James Array" <[EMAIL PROTECTED]> wrote:
> >Haloo
> >
> > I'm confusing of how to port DBI CGI to
> Apache::DBI mod_perl with
> >Apache::Registry
> >for the most efficient:
> >
> >if my normal DBI CGI is:
> >
> >use strict;
> >use DBI;
> >
> >my $dbh=DBI->connect("database","login","password","mysql");
> >......
> >$dbh->disconnect;
> >
> >=========================================================
> >
> >when port to Apache::DBI should I modify it as
> >1:
> >
> >use strict;
> >use DBI;
> >use vars qw($dbh);
> >
> >$dbh=DBI->connect("database","login","password","mysql");
> >........
> >$dbh->disconnect;
> >
>
> This would be a good try. If Apache::DBI is loaded first, it
> will cache
> connections and create a new one only if there isn't an
> existing connection
> for the particular combination of connection arguments. More
> details should
> available in the Apache::DBI perldoc.
>
> You definitely want to go with a `use vars' for $dbh if it
> can't be localized
> to a subroutine. But then, I haven't done Apache::Registry
> scripts for so
> long, I can't remember for sure (most of my code now is
> modules). You might
> want to check out the mod_perl Guide on that one.
> --
> James Smith <[EMAIL PROTECTED]>, 979-862-3725
> Texas A&M CIS Operating Systems Group, Unix
>
>