[Dbix-class] has_one joining through another table

Steve Francia steve at takkle.com
Wed Jun 27 18:39:58 GMT 2007


Sorry the code in that previous post was a bit mixed up... I have
revised it.
> in picture:
> __PACKAGE__->has_one(picture_owner => 'Schema::UserPicture', { 'foreign.user_picture_id' => 'self.fk_user_picture_id' }, { proxy => [ qw/owner/], } );
>
> in user_picture:
> __PACKAGE__->has_one(owner => 'Schema::User', { 'foreign.user_id' => 'self.fk_user_id' } );
>
> and in my search:
>     my $rs = $self->search(
>             undef,
>             {
>             join => [qw/ user_picture/ ],
>             prefetch => [qw/ user_picture/ ]
>             }
>         );
>
> -Steve
>> I'd implement that with the has_many + prefetch + proxy approach I suggested
>> in my original reply in this thread - which was based on the mistaken
>> assumption that what the OP was doing was what you just described :)
>>     
-- 
Steve Francia
Lead Developer
Takkle, Inc.
212.792.5859 (fax)
steve at takkle.com




More information about the Dbix-class mailing list