[Dbix-class] many_to_many data access

Patrick Meidl patrick at pantheon.at
Thu Jul 12 18:39:26 GMT 2012


On Thu, Jul 12 2012, fREW Schmidt <frioux at gmail.com> wrote:

> On Thu, Jul 12, 2012 at 2:48 AM, Patrick Meidl <patrick at pantheon.at> wrote:
> 
> > first, to get the cities associated to the store, use the many_to_many
> > relationship you defined; if you have such a relationship, you usually
> > never use the bridging table (store_cities in your example) directly.
> 
> I disagree.  The use of data other than left_id and right_id is what
> makes many_to_many jointables so awesome.
[...]
> It's a very handy and powerful pattern.

agreed, that's very useful, and I use often myself. but in the OP's use
case, there was a plain join table, and I think the cool thing about
many_to_many in DBIc is that you can treat your object relationships in
a much more "natural" way, i.e. ignore the fact that your underlying
database needs a join table to represent the relationship, and focus on
the domain model point-of-view.

but as I said, I didn't want to say that you shouldn't use join tables
to hold additional data if it's handy for modelling your data.

    patrick

-- 
Patrick Meidl ........................ patrick at pantheon.at
Vienna, Austria ...................... http://gplus.to/pmeidl




More information about the DBIx-Class mailing list