| 1 |
NAME |
| 2 |
Class::DBI::Loader - Dynamic definition of Class::DBI sub classes. |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use Class::DBI::Loader; |
| 6 |
|
| 7 |
my $loader = Class::DBI::Loader->new( |
| 8 |
dsn => "dbi:mysql:dbname", |
| 9 |
user => "root", |
| 10 |
password => "", |
| 11 |
namespace => "Data", |
| 12 |
additional_classes => qw/Class::DBI::AbstractSearch/, |
| 13 |
additional_base_classes => qw/My::Stuff/, |
| 14 |
constraint => '^foo.*', |
| 15 |
relationships => 1 |
| 16 |
); |
| 17 |
my $class = $loader->find_class('film'); # $class => Data::Film |
| 18 |
my $obj = $class->retrieve(1); |
| 19 |
|
| 20 |
use with mod_perl |
| 21 |
|
| 22 |
in your startup.pl |
| 23 |
|
| 24 |
# load all tables |
| 25 |
use Class::DBI::Loader; |
| 26 |
my $loader = Class::DBI::Loader->new( |
| 27 |
dsn => "dbi:mysql:dbname", |
| 28 |
user => "root", |
| 29 |
password => "", |
| 30 |
namespace => "Data", |
| 31 |
); |
| 32 |
|
| 33 |
in your web application. |
| 34 |
|
| 35 |
use strict; |
| 36 |
|
| 37 |
# you can use Data::Film directly |
| 38 |
my $film = Data::Film->retrieve($id); |
| 39 |
|
| 40 |
DESCRIPTION |
| 41 |
Class::DBI::Loader automate the definition of Class::DBI sub-classes. |
| 42 |
scan table schemas and setup columns, primary key. |
| 43 |
|
| 44 |
class names are defined by table names and namespace option. |
| 45 |
|
| 46 |
+-----------+-----------+-----------+ |
| 47 |
| table | namespace | class | |
| 48 |
+-----------+-----------+-----------+ |
| 49 |
| foo | Data | Data::Foo | |
| 50 |
| foo_bar | | FooBar | |
| 51 |
+-----------+-----------+-----------+ |
| 52 |
|
| 53 |
Class::DBI::Loader supports MySQL, Postgres and SQLite. |
| 54 |
|
| 55 |
See Class::DBI::Loader::Generic. |
| 56 |
|
| 57 |
AUTHOR |
| 58 |
Sebastian Riedel, "[email protected]" |
| 59 |
|
| 60 |
AUTHOR EMERITUS |
| 61 |
IKEBE Tomohiro, "[email protected]" |
| 62 |
|
| 63 |
THANK YOU |
| 64 |
Randal Schwartz, Simon Flack and all the others who've helped. |
| 65 |
|
| 66 |
LICENSE |
| 67 |
This library is free software; you can redistribute it and/or modify it |
| 68 |
under the same terms as Perl itself. |
| 69 |
|
| 70 |
SEE ALSO |
| 71 |
Class::DBI, Class::DBI::mysql, Class::DBI::Pg, Class::DBI::SQLite, |
| 72 |
Class::DBI::Loader::Generic, Class::DBI::Loader::mysql, |
| 73 |
Class::DBI::Loader::Pg, Class::DBI::Loader::SQLite |
| 74 |
|