[Dbix-class] Backrefernce to parent object

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Oct 4 08:02:26 GMT 2010


Rolf Schaufelberger wrote:
> Hi, 
> 
> suppose  I have a table  users  and a table address with a many-to many relation between users and addresses.
> 
> Now when I fetch a user object and I call an address method    like   $user->address({  search args})->first->do_something()
> Is there a way   in do_someting to access  the calling user object ?

This boils down to "if I have an $address how do I get the user it belongs_to".
Which in turn requires you simply declare a belongs_to relationship on
Address pointing to User. Or am I missing something here?



More information about the DBIx-Class mailing list