X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship.pm;h=5d29e690190a185d38489aa32fe21928e2cdf83a;hb=0180bef9e132569a564a1171c6dfb318a2f6de27;hp=d159cc490d3ee0df56bd45f0e96b496a1020b3ca;hpb=da2e2b76bdec7372d0cf3a58214a6af2c1695a8e;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship.pm b/lib/DBIx/Class/Relationship.pm index d159cc4..5d29e69 100644 --- a/lib/DBIx/Class/Relationship.pm +++ b/lib/DBIx/Class/Relationship.pm @@ -222,12 +222,13 @@ methods and valid relationship attributes. =back -Creates a one-to-many relationship, where the corresponding elements of the -foreign class store the calling class's primary key in one (or more) of its -columns. This relationship defaults to using C<$accessor_name> as the foreign -key in C<$related_class> to resolve the join, unless C<$foreign_key_column> -specifies the foreign key column in C<$related_class> or C specifies a -reference to a join condition hash. +Creates a one-to-many relationship, where the corresponding elements +of the foreign class store the calling class's primary key in one (or +more) of its columns. This relationship defaults to using the end of +this classes namespace as the foreign key in C<$related_class> to +resolve the join, unless C<$foreign_key_column> specifies the foreign +key column in C<$related_class> or C specifies a reference to a +join condition hash. =over @@ -273,25 +274,27 @@ OR condition. =back # in an Author class (where Author has_many Books) + # assuming related class is storing our PK in "author_id" My::DBIC::Schema::Author->has_many( books => 'My::DBIC::Schema::Book', 'author_id' ); - # OR (same result, assuming related_class is storing our PK) + # OR (same result) My::DBIC::Schema::Author->has_many( books => 'My::DBIC::Schema::Book', + { 'foreign.author_id' => 'self.id' }, ); - - # OR (same result) + + # OR (similar result, assuming related_class is storing our PK, in "author") + # (the "author" is guessed at from "Author" in the class namespace) My::DBIC::Schema::Author->has_many( books => 'My::DBIC::Schema::Book', - { 'foreign.author_id' => 'self.id' }, ); - + # Usage # resultset of Books belonging to author @@ -380,7 +383,7 @@ OR =item cond A hashref where the keys are C and -the values are C. This is useful for +the values are C. This is useful for relations that are across multiple columns. =back @@ -458,7 +461,7 @@ OR =item cond A hashref where the keys are C and -the values are C. This is useful for +the values are C. This is useful for relations that are across multiple columns. =back