Rob Kinyon wrote:
On Mon, Oct 4, 2010 at 04:02, Peter Rabbitson <[email protected]> wrote:
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?
Peter - you're missing the "many-to-many" relationship bit.
Rolf - a Row object is completely stand-alone. There is no direct
relationship between the $user that did the search and the $address.
You're going to have to pass $user into do_something() if you want to
have access to it.
What Rob said above. Apologies for missing a crucial part of the
question :)
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]