Matt S Trout > DBIx-Class-0.03 > DBIx::Class::Relationship

Download:
DBIx-Class-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  11
Open  18
Stalled  11
View/Report Bugs
Source   Latest Release: DBIx-Class-0.082810

NAME ^

DBIx::Class::Relationship - Inter-table relationships

SYNOPSIS ^

DESCRIPTION ^

This class handles relationships between the tables in your database model. It allows your to set up relationships, and to perform joins on searches.

This POD details only the convenience methods for setting up standard relationship types. For more information see ::Relationship::Base

METHODS ^

All convenience methods take a signature of the following format -

  __PACKAGE__>method_name('relname', 'Foreign::Class', $join?, $attrs?);
has_one
  my $f_obj = $obj->relname;

Creates a one-one relationship with another class; defaults to PK-PK for the join condition unless a condition is specified.

might_have
  my $f_obj = $obj->relname;

Creates an optional one-one relationship with another class; defaults to PK-PK for the join condition unless a condition is specified.

has_many
  my @f_obj = $obj->relname($cond?, $attrs?);
  my $f_result_set = $obj->relname($cond?, $attrs?);

  $obj->add_to_relname(\%col_data);

Creates a one-many relationship with another class;

belongs_to
  my $f_obj = $obj->relname;

  $obj->relname($new_f_obj);

Creates a relationship where we store the foreign class' PK; if $join is a column name instead of a condition that is assumed to be the FK, if not has_many assumes the FK is the relname is that is a column on the current class.

AUTHORS ^

Matt S. Trout <mst@shadowcatsystems.co.uk>

LICENSE ^

You may distribute this code under the same terms as Perl itself.

syntax highlighting: