[Dbix-class] Multiple belongs_to relationships referencing same class

Brandon Black blblack at gmail.com
Wed Apr 25 22:10:05 GMT 2007


On 4/25/07, Tobias Kremer <list at funkreich.de> wrote:
>
> Am 25.04.2007 um 22:42 schrieb Brandon Black:
>
> > On 4/25/07, Tobias Kremer <list at funkreich.de> wrote:
> >> Hi folks,
> >>
> >> I have a table which has two columns referencing the same class,
> >> something
> >> like this:
> >
> > You don't give a lot of details on what the failing behavior actually
> > is, but I'm guessing that at least one problem you're having is that
> > you're proxying the same column names into the local class twice from
> > two different relationships.  This might be a good place to not use
> > proxy, considering the conflict.
>
> Sounds like my kind of problem - what are the alternatives to proxy?

One alternative to proxy is just to not use proxy.  Proxy is merely
convenience.  Instead of saying $user_relation_object->username (which
is ambiguous given your duplicate proxy statements), say
$user_relation_object->requestor->username or
$user_relation_object->receiver->username.

Or you could make some custom accessors called requestor_username, etc
to do this for you.

-- Brandon



More information about the Dbix-class mailing list