Gantry::Utils::DBConnHelper::Script - connection info and dbh cache manager for scripts


Gantry documentation Contained in the Gantry distribution.

Index


Code Index:

NAME

Top

Gantry::Utils::DBConnHelper::Script - connection info and dbh cache manager for scripts

SYNOPSIS

Top

    use Gantry::Utils::DBConnHelper::Script {
        dbconn => 'dbi:Pg:dbname=mydb;host=127.0.0.1',
        dbuser => 'someuser',
        dbpass => 'not_saying',
    };

OR

    use Gantry::Utils::DBConnHelper::Script;

    # ... do something, usually involving figuring out your conn info

    Gantry::Utils::DBConnHelper::Script->set_conn_info( $conn_info_hash_ref );

In either case, if you need httpd authentication (say in CGI):

    Gantry::Utils::DBConnHelper::Script->set_auth_conn_info(
            $auth_conn_hash_ref
    );

DESCRIPTION

Top

When you use a model which inherits from Gantry::Utils::CDBI or Gantry::Utils::Model etc., using this module can help with database connection management. Feel free to implement your own subclass of Gantry::Utils::DBConnHelper if you need more control. That base class specifies which methods you must implement.

Normal Connection METHODS

Top

See Gantry::Utils::DBConnHelper for a description of the methods available here.

Note that only cgi scripts need to worry about the auth methods. Off line scripts don't need to authenticate through apache.

Here is a list of the methods documented in Gantry::Utils::DBConnHelper.

get_auth_conn_info
get_auth_dbh
get_conn_info
get_dbh
set_auth_conn_info
set_auth_dbh
set_conn_info
set_dbh

AUTHOR

Top

Phil Crow <philcrow2000@yahoo.com>

COPYRIGHT and LICENSE

Top


Gantry documentation Contained in the Gantry distribution.

package Gantry::Utils::DBConnHelper::Script;
use strict; use warnings;

use base 'Gantry::Utils::DBConnHelper';

Gantry::Utils::DBConnHelper->set_subclass(
    'Gantry::Utils::DBConnHelper::Script'
);

my $dbh;
my $conn_info;

my $auth_dbh;
my $auth_conn_info;

sub get_dbh {
    return $dbh;
}

sub set_dbh {
    my $class = shift;
    $dbh      = shift;
}

sub get_conn_info {
    return $conn_info;
}

sub set_conn_info {
    my $class  = shift;
    $conn_info = shift;
}

#-----------------------------------------------------------------
# The methods below are for cgi scripts which use auth databases.
#-----------------------------------------------------------------

sub get_auth_dbh {
    return $auth_dbh;
}

sub set_auth_dbh {
    my $class = shift;
    $auth_dbh = shift;
}

sub get_auth_conn_info {
    return ( $auth_conn_info ) ? $auth_conn_info : $conn_info;
}

sub set_auth_conn_info {
    my $class       = shift;
    $auth_conn_info = shift;
}

1;