NAME
Handel::DBI - Base DBI class used by cart/order objects
SYNOPSIS
use Handel::DBI;
my $newid = Handel::DBI::uuid;
my $newid = Handel::DBI->uuid;
my $newid = Handel::Cart->uuid;
my $newid = Handel::Cart::Item->uuid;
..etc...
DESCRIPTION
This is the main base class for Handel objects that access the database. There shouldn't be any reason to use this module directly for now.
METHODS
add_columns(@columns)
Adds columns to the current objects database schema. This is used to add custom fields when subclassing Cart/Items and Order/Items.
package CustomCart;
use base 'Handel::Cart';
__PACKAGE__->add_columns(qw/created lastskuadded/);
In addition to id/shopper/type/name and description, CustomCart now has create and lastskuadded fields.
NOTE: Make sure to alter your database schema to include these new fields.
FUNCTIONS
uuid
Returns a guid/uuid using the first available uuid generation module. The support modules are UUID
, Data::UUID
, Win32::Guidgen
, and Win32API::GUID
.
use Handel::DBI;
my $newid = Handel::DBI::uuid;
my $uuid = Handel::DBI->uuid;
Since Handel::Cart
and Handel::Cart::Item
are subclasses of Handel::DBI
, uuid
is available within those modules as a method/function as well:
use Handel::Cart;
my $newid = Handel::Cart->uuid;
has_wildcard
Inspects the supplied search filter to determine whether it contains wildcard searching. Returns 1 if the filter contains SQL wildcards, otherwise it returns undef
.
has_wildcard({sku => '12%'}); # 1
has_wildcard((sku => '123')); # undef
This is used by Handel::Cart->items
and Handel::Cart::load
to determine which Class::DBI methods to call (search vs. search_like).
CONFIGURATION
Starting in version 0.16
, the DBI configuration variables have been changed. The old variables are now considered deprecated and will be removed in the future.
These can either be set in ENV
, or using PerlSetVar in httpd.conf
. IF you are already using ENV
variables and want to use them within Apache instead of duplicating that config using PerlSetVar
, you can tell mod_perl to pass that configuration in by using PerlPassEnv
.
At some point, this needs to be reworked into a more generic config loader so we can use ENV
, httpd.conf directives, or config files, LDAP, etc.
Handel::DBI
constructs its connection string using the following variables:
HandelDBIDriver
The name of the DBD driver. Defaults to mysql
.
HandelDBIHost
The name of the database server. Defaults to localhost
.
HandelDBIPort
The port of the database server. Defaults to 3306
.
HandelDBIName
The name of the database. Defaults to commerce
.
HandelDBIUser
The user name used to connect to the server. Defaults to commerce
.
HandelDBIPassword
The password used to connect to the server. Defaults to commerce
.
HandelDBIDSN
The full data source to the connect to the database. If a dsn is supplied the driver/host/port and name are ignored. IF no dsn is supplied, one will will be constructed from driver/host/port and name.
SEE ALSO
UUID, Data::UUID, Win32::Guidgen, Win32API::GUID
AUTHOR
Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/