[Dbix-class] more complex relationships

Matt S Trout dbix-class at trout.me.uk
Fri Mar 24 15:21:03 CET 2006


Jess Robinson wrote:
> I'd still like to see the DBIx::Class code..
> 
> So, if I read it correctly now, from sale_item, which has a sale_id and a 
> product_d, you want to get the entry in vendor_product?
> 
> $schema->resultset('VendorProduct')->find({vendor_name =>
>                                     $saleitem->sale->vendor_name,
>                                    product_id =>
>                                      $saleitem->product_id});
> ?
> 
> .. so it wants a sort of infinite level relationship search similar to how 
> we do it with joins already?

I think what we're basically looking at here is a relationship that's only 
valid on a sort-of-a-view across two tables. So something like

->add_relationship('vendor_product', 'My::VendorProduct', { 
'foreign.vendor_name' => 'self.sale.vendor_name', foreign.product_id => 
'self.product_id' });

or so. Does that make sense to anybody else?

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list