Gantry::Utils::CDBI - Class::DBI base class for Gantry applications
This module expects to retrieve the database connection, username, and password from one of two places.
If it lives in mod_perl, it expects these to come from the apache conf file. You might supply them like this:
<Location / > PerlSetVar dbconn 'dbi:Pg:dbname=your_db_name' PerlSetVar dbuser 'your_user' PerlSetVar dbpass 'your_password' </Location>
It then retrieves them roughly like this (the mod_perl version affects this):
$r = Apache->request(); $r->dir_config( 'dbconn' ), $r->dir_config( 'dbuser' ), $r->dir_config( 'dbpass' ),
The handle is cached using pnotes to avoid recreating it.
On the other hand, if the module does not live in mod_perl, it needs to directly use Gantry::Utils::DBConnHelper::Script like this:
use Gantry::Utils::DBConnHelper::Script { dbconn => 'dbi:Pg:dbname=your_db_name', dbuser => 'your_user', dbuser => 'your_pass', };
If you can't put the connection info into the use statement (say because you take it from the command line) do the above in two steps:
use Gantry::Utils::DBConnHelper::Script; # figure out your connection info Gantry::Utils::DBConnHelper::Script->set_conn_info( dbconn => $dsn, dbuser => $dbuser, dbuser => $dbpass, );
The database handle is cached by the helper. To get hold of it say:
my $dbh = Gantry::Utils::DBConnHelper::Script->get_dbh();
This module provides the base methods for Class:DBI, including the db conection method within a mod_perl environment.
Default database attributes usually supplied by Class::DBI's _default_attributes method.
A failed attempt at date format beautification. Probably should be removed.
Note that these other methods are mixed in from Gantry::Utils::ModelHelper:
db_Main retrieve_all_for_main_listing get_form_selections
See its docs for details.
Tim Keefer <tkeefer@gmail.com>
Copyright (c) 2005-6, Tim Keefer.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Gantry, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gantry
CPAN shell
perl -MCPAN -e shell install Gantry
For more information on module installation, please visit the detailed CPAN module installation guide.