1Relationship(3)       User Contributed Perl Documentation      Relationship(3)
2
3
4

NAME

6       Class::DBI::Loader::Relationship - Easier relationship specification in
7       CDBI::Loader
8

SYNOPSIS

10         use Class::DBI::Loader::Relationship;
11
12         my $loader = Class::DBI::Loader->new( dsn => "mysql:beerdb",
13                                               namespace => "BeerDB");
14
15       Now instead of saying
16
17           BeerDB::Brewery->has_many(beers => "BeerDB::Beer");
18           BeerDB::Beer->has_a(brewery => "BeerDB::Brewery");
19
20           BeerDB::Handpump->has_a(beer => "BeerDB::Beer");
21           BeerDB::Handpump->has_a(pub => "BeerDB::Pub");
22           BeerDB::Pub->has_many(beers => [ BeerDB::Handpump => 'beer' ]);
23           BeerDB::Beer->has_many(pubs => [ BeerDB::Handpump => 'pub' ]);
24
25       Just say
26
27           $loader->relationship( "a brewery produces beers" );
28           $loader->relationship( "a pub has beers on handpumps" );
29
30       And something like ( upgraded in v1.3 )
31
32           MyApp::Page->has_a( author => 'MyApp::User' );
33           MyApp::Page->has_many( revisions => 'MyApp::PageRevision' );
34
35       Just say
36
37           $loader->relationship( "a page has an user as author" );
38           $loader->relationship( "a page has many page_revisions as revisions" );
39

DESCRIPTION

41       This module acts as a mix-in, adding the "relationship" method to
42       "Class::DBI::Loader". Since "Class::DBI::Loader" knows how to map
43       between table names and class names, there ought to be no need to
44       replicate the names.
45
46       In addition, it is common (but not universal) to want reverse
47       relationships defined for has-many relationships, and for has-a
48       relationships to be defined for the linkages surrounding a many-to-many
49       table.
50
51       The aim of "CDBIL::Relationship" is to simplify the declaration of
52       common database relationships by providing both of these features.
53
54       The "relationship" takes a string. It recognises table names (singular
55       or plural, for convenience) and extracts them from the "sentence".
56

AUTHOR

58       Simon Cozens, "simon@cpan.org"
59
60       Chunzi, "chunzi@perlchina.org"
61

SEE ALSO

63       Class::DBI::Loader.
64
65
66
67perl v5.28.1                      2005-11-09                   Relationship(3)
Impressum