Moved might_have compat back out into a CDBICompat class and documented stuff
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Relationship.pm
1 package DBIx::Class::Relationship;
2
3 use strict;
4 use warnings;
5
6 use base qw/DBIx::Class Class::Data::Inheritable/;
7
8 __PACKAGE__->load_own_components(qw/
9   HasMany
10   HasOne
11   BelongsTo
12   Accessor
13   CascadeActions
14   ProxyMethods
15   Base
16 /);
17
18 __PACKAGE__->mk_classdata('_relationships', { } );
19
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
32 This POD details only the convenience methods for setting up standard
33 relationship types. For more information see ::Relationship::Base
34
35 =head1 METHODS
36
37 All convenience methods take a signature of the following format -
38
39   __PACKAGE__>method_name('relname', 'Foreign::Class', $join?, $attrs?);
40
41
42
43 =over 4
44
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
79 =cut
80
81 1;
82
83 =back
84
85 =head1 AUTHORS
86
87 Matt S. Trout <mst@shadowcatsystems.co.uk>
88
89 =head1 LICENSE
90
91 You may distribute this code under the same terms as Perl itself.
92
93 =cut
94