Commit | Line | Data |
b8e1e21f |
1 | package DBIx::Class::Relationship; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
1edd1722 |
6 | use base qw/DBIx::Class/; |
55e2d745 |
7 | |
07037f89 |
8 | __PACKAGE__->load_own_components(qw/ |
9 | HasMany |
10 | HasOne |
11 | BelongsTo |
12 | Accessor |
13 | CascadeActions |
14 | ProxyMethods |
15 | Base |
16 | /); |
b8e1e21f |
17 | |
18 | __PACKAGE__->mk_classdata('_relationships', { } ); |
19 | |
34d52be2 |
20 | =head1 NAME |
21 | |
22 | DBIx::Class::Relationship - Inter-table relationships |
23 | |
24 | =head1 SYNOPSIS |
25 | |
26 | =head1 DESCRIPTION |
27 | |
28 | This class handles relationships between the tables in your database |
29 | model. It allows your to set up relationships, and to perform joins |
30 | on searches. |
31 | |
503536d5 |
32 | This POD details only the convenience methods for setting up standard |
33 | relationship types. For more information see ::Relationship::Base |
34 | |
34d52be2 |
35 | =head1 METHODS |
36 | |
503536d5 |
37 | All convenience methods take a signature of the following format - |
38 | |
39 | __PACKAGE__>method_name('relname', 'Foreign::Class', $join?, $attrs?); |
40 | |
41 | |
42 | |
34d52be2 |
43 | =over 4 |
44 | |
503536d5 |
45 | =item has_one |
46 | |
47 | my $f_obj = $obj->relname; |
48 | |
49 | Creates a one-one relationship with another class; defaults to PK-PK for |
50 | the join condition unless a condition is specified. |
51 | |
52 | =item might_have |
53 | |
54 | my $f_obj = $obj->relname; |
55 | |
56 | Creates an optional one-one relationship with another class; defaults to PK-PK |
57 | for the join condition unless a condition is specified. |
58 | |
59 | =item has_many |
60 | |
61 | my @f_obj = $obj->relname($cond?, $attrs?); |
62 | my $f_result_set = $obj->relname($cond?, $attrs?); |
63 | |
64 | $obj->add_to_relname(\%col_data); |
65 | |
66 | Creates a one-many relationship with another class; |
67 | |
68 | =item belongs_to |
69 | |
70 | my $f_obj = $obj->relname; |
71 | |
72 | $obj->relname($new_f_obj); |
73 | |
74 | Creates a relationship where we store the foreign class' PK; if $join is a |
75 | column name instead of a condition that is assumed to be the FK, if not |
76 | has_many assumes the FK is the relname is that is a column on the current |
77 | class. |
78 | |
34d52be2 |
79 | =cut |
80 | |
b8e1e21f |
81 | 1; |
34d52be2 |
82 | |
83 | =back |
84 | |
85 | =head1 AUTHORS |
86 | |
daec44b8 |
87 | Matt S. Trout <mst@shadowcatsystems.co.uk> |
34d52be2 |
88 | |
89 | =head1 LICENSE |
90 | |
91 | You may distribute this code under the same terms as Perl itself. |
92 | |
93 | =cut |
94 | |