-
-
22 Mar 2007 11:37:16 UTC
- Distribution: Class-DBI-Loader
- Module version: 0.34
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (14)
- Testers (2058 / 1 / 0)
- Kwalitee
Bus factor: 6- 78.89% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (9.94KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Class::DBI
- DBI
- Lingua::EN::Inflect
- Test::More
- Text::Balanced
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Class::DBI::Loader - Dynamic definition of Class::DBI sub classes.
SYNOPSIS
use Class::DBI::Loader; my $loader = Class::DBI::Loader->new( dsn => "dbi:mysql:dbname", user => "root", password => "", options => { RaiseError => 1, AutoCommit => 0 }, namespace => "Data", additional_classes => qw/Class::DBI::AbstractSearch/, # or arrayref additional_base_classes => qw/My::Stuff/, # or arrayref left_base_classes => qw/Class::DBI::Sweet/, # or arrayref constraint => '^foo.*', relationships => 1, options => { AutoCommit => 1 }, inflect => { child => 'children' }, require => 1 ); my $class = $loader->find_class('film'); # $class => Data::Film my $obj = $class->retrieve(1);
use with mod_perl
in your startup.pl
# load all tables use Class::DBI::Loader; my $loader = Class::DBI::Loader->new( dsn => "dbi:mysql:dbname", user => "root", password => "", namespace => "Data", );
in your web application.
use strict; # you can use Data::Film directly my $film = Data::Film->retrieve($id);
DESCRIPTION
Class::DBI::Loader automate the definition of Class::DBI sub-classes. scan table schemas and setup columns, primary key.
class names are defined by table names and namespace option.
+-----------+-----------+-----------+ | table | namespace | class | +-----------+-----------+-----------+ | foo | Data | Data::Foo | | foo_bar | | FooBar | +-----------+-----------+-----------+
Class::DBI::Loader supports MySQL, Postgres and SQLite.
See Class::DBI::Loader::Generic.
METHODS
new %args
- additional_base_classes
-
List of additional base classes your table classes will use.
- left_base_classes
-
List of additional base classes, that need to be leftmost, for example Class::DBI::Sweet (former Catalyst::Model::CDBI::Sweet).
- additional_classes
-
List of additional classes which your table classes will use.
- constraint
-
Only load tables matching regex.
- exclude
-
Exclude tables matching regex.
- debug
-
Enable debug messages.
- dsn
-
DBI Data Source Name.
- namespace
-
Namespace under which your table classes will be initialized.
- password
-
Password.
- options
-
Optional hashref to specify DBI connect options
- relationships
-
Try to automatically detect/setup has_a and has_many relationships.
- inflect
-
An hashref, which contains exceptions to Lingua::EN::Inflect::PL(). Useful for foreign language column names.
- user
-
Username.
- require
-
Attempt to require the dynamically defined module, so that extensions defined in files. By default errors from imported modules are suppressed. When you want to debug, use require_warn.
- require_warn
-
Warn of import errors when requiring modules.
AUTHOR
Daisuke Maki
dmaki@cpan.org
AUTHOR EMERITUS
Sebastian Riedel,
sri@oook.de
IKEBE Tomohiro,ikebe@edge.co.jp
THANK YOU
Adam Anderson, Andy Grundman, Autrijus Tang, Dan Kubb, David Naughton, Randal Schwartz, Simon Flack and all the others who've helped.
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Class::DBI, Class::DBI::mysql, Class::DBI::Pg, Class::DBI::SQLite, Class::DBI::Loader::Generic, Class::DBI::Loader::mysql, Class::DBI::Loader::Pg, Class::DBI::Loader::SQLite
Module Install Instructions
To install Class::DBI::Loader, copy and paste the appropriate command in to your terminal.
cpanm Class::DBI::Loader
perl -MCPAN -e shell install Class::DBI::Loader
For more information on module installation, please visit the detailed CPAN module installation guide.