1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
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 => "",
namespace => "Data",
additional_classes => qw/Class::DBI::AbstractSearch/,
additional_base_classes => qw/My::Stuff/,
constraint => '^foo.*',
relationships => 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.
AUTHOR
Sebastian Riedel, "sri@oook.de"
AUTHOR EMERITUS
IKEBE Tomohiro, "ikebe@edge.co.jp"
THANK YOU
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
|