Class::DBI::Factory is a factory interface to a set of Class::DBI classes, with optional mod_perl application skeleton.
SYNOPSIS
# in a simple script:
my $factory = Class::DBI::Factory->new;
$factory->set_db({
db_type => 'mysql',
db_name => 'items',
db_username => 'me',
db_password => 'password',
});
$factory->use_classes(qw(My::Item));
my @columns = $factory->columns('item');
my $item = $factory->retrieve('item', 1);
my $iterator = $factory->search('item', year => 1980);
# in an apache host configuration:
PerlSetEnv _CDF_SITE_CONFIG '/home/my_site/conf/cdf.conf'
< Location "/directory" >
SetHandler perl-script
PerlHandler Class::DBI::Factory::Handler
< /Location >
# and on a template somewhere:
< p >
[% FOREACH album IN factory.search('album',
'year', input.year,
'artist', artist,
) %][% album.title %]< br >[% END %]
< /p >
INTRODUCTION
If you use Class::DBI::Factory by itself, it's a quick, clean way to work with a set of Class::DBI data classes, providing a simple way to access their data and class methods and removing some of cdbi's limitations: with the factory it's very easy to use the same data classes for different databases at the same time.
If you use Class::DBI::Factory with the set of helper classes that come with it, it's a full framework for MVC-friendly mod_perl-based web applications. The supplied Handler base class makes the factory's simple, consistent interface available on TT2 (or other) templates and hides all the complexity of working under mod_perl. In this context the database-abstraction that the factory offers allows you to use the same application on several sites on the same server, which is where all this began many years ago.
CDF is a simple alternative to application frameworks like Maypole and Catalyst. It doesn't automate the creation of CDBI classes - I prefer to write them - but it handles pretty much everything else and is very easy to extend and override.
Product's homepage
Requirements:
· Perl