NAME

ClearPress::util - A database handle and utility object

VERSION

$Revision: 388 $

SYNOPSIS

DESCRIPTION

SUBROUTINES/METHODS

new - Constructor

my $oUtil = ClearPress::util->new({
                            'configpath' => '/path/to/config.ini', # Optional
                           });

data_path - Accessor to data directory containing config.ini and template subdir

my $sPath = $oUtil->data_path();

configpath - Get/set accessor for path to config file

$oUtil->configpath('/path/to/configfile/');

my $sConfigPath = $oUtil->configpath();

config - The Config::IniFiles object for our configpath

my $oConfig = $oUtil->config();

driver - driver name from config.ini

my $sDriverName = $oUtil->driver();

dbsection - dev/test/live/application based on $ENV{dev}

my $sSection = $oUtil->dbsection();

dbh - A database handle for the supported database

my $oDbh = $oUtil->dbh();

quote - Shortcut for $oDbh->quote('...');

my $sQuoted = $oUtil->quote($sUnquoted);

transactions - Enable/disable transaction commits

Example: A cascade of object saving

 $util->transactions(0);                       # disable transactions

 for my $subthing (@{$thing->subthings()}) {   # cascade object saves (without commits)
   $subthing->save();
 }

 $util->transactions(1);                       # re-enable transactions
 $thing->save();                               # save parent object (with commit)

username - Get/set accessor for requestor's username

$oUtil->username((getpwuid $<)[0]);
$oUtil->username($sw->username());

my $sUsername = $oUtil->username();

cgi - Placeholder for a CGI object (or at least something with the same param() interface)

$oUtil->cgi($oCGI);
my $oCGI = $oUtil->cgi();

session - Placeholder for a session hashref

$oUtil->session($hrSession);
my $hrSession = $oUtil->session();

profiler - Placeholder for a Website::Utilities::Profiler object

$oUtil->profiler($oProfiler);
my $oProf = $oUtil->profiler();

requestor - a ClearPress::model::user who requested this page (constructed by view.pm)

This is usually used for testing group membership for authorisation checks

my $oRequestingUser = $oUtil->requestor();

log - Formatted debugging output to STDERR

$oUtil->log(@aMessages);

cleanup - housekeeping stub for subclasses - called when response has completed processing

$oUtil->cleanup();

db_credentials - hashref of database connection info from the current dbsection

my $hrDBHInfo = $oUtil->db_credentials();

dbname - database name from db_credentials

my $sDBName = $oUtil->dbname();

dbuser - database user from db_credentials

my $sDBUser = $oUtil->dbuser();

dbpass - database pass from db_credentials

my $sDBPass = $oUtil->dbpass();

dbhost - database host from db_credentials

my $sDBHost = $oUtil->dbhost();

dbport - database port from db_credentials

my $sDBPort = $oUtil->dbport();

DIAGNOSTICS

CONFIGURATION AND ENVIRONMENT

DEPENDENCIES

strict
warnings
DBI
Config::IniFiles
Carp
POSIX
English
Class::Singleton

INCOMPATIBILITIES

BUGS AND LIMITATIONS

AUTHOR

Roger Pettett, <rpettett@cpan.org>

LICENSE AND COPYRIGHT

Copyright (C) 2008 Roger Pettett

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.4 or, at your option, any later version of Perl 5 you may have available.