X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship.pm;h=b95867f01077542e150dcaf14d0526f15fe43850;hb=63cab14709baf8dd679bfb150e04f3a6cfcc548c;hp=6a5a04656a101bc2dd573ebdf38ee2ed7f7c7c85;hpb=9e64dfbf92b14c3dac77cf4ed8a8842114cdbfe5;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Relationship.pm b/lib/DBIx/Class/Relationship.pm index 6a5a046..b95867f 100644 --- a/lib/DBIx/Class/Relationship.pm +++ b/lib/DBIx/Class/Relationship.pm @@ -125,7 +125,7 @@ The above belongs_to relationship could also have been specified as, My::DBIC::Schema::Book->belongs_to( author, 'My::DBIC::Schema::Author', - { 'self.author' => 'foreign.author' } ); + { 'foreign.author' => 'self.author' } ); Creates a relationship where the calling class stores the foreign class's primary key in one (or more) of its columns. This relationship defaults to @@ -308,9 +308,16 @@ And, for the reverse relationship, from Role to Actor: My::DBIC::Schema::Role->many_to_many( actors => 'actor_roles', 'actor' ); -Creates accessors bridging two relationships; not strictly a relationship in -its own right, although the accessor will return a resultset or collection of -objects just as a has_many would. +To add a role for your actor, and fill in the year of the role in the +actor_roles table: + + $actor->add_to_roles($role, { year => 1995 }); + +Many_to_many is not strictly a relationship in its own right. Instead, it is +a bridge between two resultsets which provide the same kind of convenience +accessors as true relationships provide. Although the accessor will return a +resultset or collection of objects just like has_many does, you cannot call +C<$related_resultset> and similar methods which operate on true relationships. In the above example, ActorRoles is the link table class, and Role is the foreign class. The C<$link_rel_name> parameter is the name of the accessor for