[Dbix-class] more complex relationships
Matt S Trout
dbix-class at trout.me.uk
Fri Mar 24 16:37:04 CET 2006
Jonas Alves wrote:
> On Friday 24 March 2006 14:21, Matt S Trout wrote:
>> 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' });
>>
>
> I also need relationships based in column constant values. eg:
>
> ->add_relationship('vendor_product', 'My::VendorProduct', {
> 'foreign.product_id' => 'self.product_id',
> 'self.product_reference' => '123'
> });
->add_relationship('vendor_product', 'My::VendorProduct',
{ 'foreign.product_id' => 'self.product_id' },
{ where => { 'vendor_product.product_reference' => 123 } }
);
--
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