On Fri, Jun 22, 2007 at 01:09:15PM -0400, Steve Francia wrote:
> I have a rather complicated relationship that I am struggling with
> setting up, hopefully I can explain it so it makes sense. I will also
> include what we have thus far.
>
> I have two tables user and friends, friends is a join table that joins
> users to users. In my system, friendship is bilateral, meaning to have a
> friend is to be one.
> I worked through the reciprocal relationship alright, but the bilateral
> part has me stumped.
You can use an OR in the join cond, although it's not always as efficient
on MySQL as you might like -
has_many(friend_link => ...::Friend => [
{ 'foreign.f1_id' => 'self.id' },
{ 'foreign.f2_id' => 'self.id' },
]);
which will do
user me JOIN friend friend_link
ON (friend_link.f1_id = me.id OR friend_link.f2_id = me.id)
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/