Merge 'trunk' into 'DBIx-Class-C3'
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Relationship.pm
CommitLineData
b8e1e21f 1package DBIx::Class::Relationship;
2
3use strict;
4use warnings;
5
55e2d745 6use base qw/DBIx::Class Class::Data::Inheritable/;
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
22DBIx::Class::Relationship - Inter-table relationships
23
24=head1 SYNOPSIS
25
26=head1 DESCRIPTION
27
28This class handles relationships between the tables in your database
29model. It allows your to set up relationships, and to perform joins
30on searches.
31
503536d5 32This POD details only the convenience methods for setting up standard
33relationship types. For more information see ::Relationship::Base
34
34d52be2 35=head1 METHODS
36
503536d5 37All 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
49Creates a one-one relationship with another class; defaults to PK-PK for
50the join condition unless a condition is specified.
51
52=item might_have
53
54 my $f_obj = $obj->relname;
55
56Creates an optional one-one relationship with another class; defaults to PK-PK
57for 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
66Creates 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
74Creates a relationship where we store the foreign class' PK; if $join is a
75column name instead of a condition that is assumed to be the FK, if not
76has_many assumes the FK is the relname is that is a column on the current
77class.
78
34d52be2 79=cut
80
b8e1e21f 811;
34d52be2 82
83=back
84
85=head1 AUTHORS
86
daec44b8 87Matt S. Trout <mst@shadowcatsystems.co.uk>
34d52be2 88
89=head1 LICENSE
90
91You may distribute this code under the same terms as Perl itself.
92
93=cut
94