The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Apache2::Controller::SQL::Connector - connects DBI to <$r-pnotes->{dbh}>>.

VERSION

Version 0.101.111 - BETA TESTING (ALPHA?)

SYNOPSIS

CONFIG ALTERNATIVE 1: APACHE CONF

 # virtualhost.conf:
 
 PerlLoadModule Apache::DBI
 PerlLoadModule Apache2::Controller::Directives
 <Location '/'>
     A2C_DBI_DSN        DBI:mysql:database=foobar;host=localhost
     A2C_DBI_User       heebee
     A2C_DBI_Password   jeebee
     A2C_DBI_Options    RaiseError  1
     A2C_DBI_Options    AutoCommit  0

     SetHandler                 modperl
     PerlInitHandler            MyApp::Dispatch
     PerlHeaderParserHandler    Apache2::Controller::SQL::Connector
 </Location>

CONFIG ALTERNATIVE 2: SUBCLASS

If you need to hide details from the server configuration tree, for example to hide password from access by untrusted cgi scripts, subclass this module and implement your own <dbi_connect_args()> subroutine, which returns argument list for <DBI-connect()>>.

 PerlLoadModule Apache::DBI
 <Location '/'>
     SetHandler                 modperl
     PerlInitHandler            MyApp::Dispatch
     PerlHeaderParserHandler    MyApp::SQLConnect
 </Location>

 package MyApp::SQLConnect;
 use base qw( Apache2::Controller::SQL::Connector );
 sub dbi_connect_args {
     my ($self) = @_;
     return (
         'DBI:mysql:database=foobar;host=localhost',
         'heebee', 'jeebee',
         { RaiseError => 1, AutoCommit => 0 }
     );
 }
 1;

METHODS

process

Gets DBI connect arguments by calling $self->dbi_connect_args(), then connects $dbh and stashes it in $r->pnotes->{dbh}.

dbi_connect_args

Default interprets directives. Apache2::Controller::Directives. You can override this in a subclass to provide your own connect args.

SEE ALSO

Apache2::Controller::Directives

Apache2::Controller::SQL::MySQL

Apache2::Controller

Apache::DBI

AUTHOR

Mark Hedges, hedges +(a t)- scriptdolphin.org

COPYRIGHT AND LICENSE

Copyright 2008 Mark Hedges. CPAN: markle

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.