[Dbix-class] Updating many-to-many relationships
David Cantrell
david at cantrell.org.uk
Wed Feb 22 17:36:58 GMT 2012
On Wed, Feb 22, 2012 at 11:18:15AM +0100, Alexander Hartmaier wrote:
> set_$helper_name replaces all rows in the link table, add_to_$helper_name adds a row to the link table.
> If you look at the code in DBIx::Class::Relationship::ManyToMany you see that set_ deletes all rows and then calls the add_to_ method for every array element, so the syntax is the same.
>
> The pod contains an example for its usage:
> $actor->add_to_roles($role, { year => 1995 });
>
> The first argument is a role object, the optional second parameter a hashref containing additional column data for the link table.
OK, but that's still not really what I'm looking for. When I INSERT
with my current code, not only does it populate the intermediate
user_role table, but it also populates - if necessary - the role table.
It would be perverse if there's nothing similar for UPDATEs.
Maybe what I'm looking for doesn't exist <shrug>.
--
David Cantrell | semi-evolved ape-thing
Immigration: making Britain great since AD43
More information about the DBIx-Class
mailing list