[Dbix-class] Prefetch and join on different tables

Patrick Meidl pmeidl at ist.ac.at
Fri Jan 18 20:17:22 GMT 2013


On Fri, Jan 18 2013, mpm <mpmagarinos at gmail.com> wrote:

> push @{ $attr->{join} }, 'mt';
> push @{ $attr->{join} }, 'mc';
> my $rs1 = $c->model('weight::Mdata')->search( $where, $attr,{prefetch =>
> 'mc'});

I think your curly braces are misplaced. this should do what you want:

my $rs1 = $c->model('weight::Mdata')->search($where,
    { %$attr, prefetch => 'mc' });

or alternatively:

push @{ $attr->{join} }, 'mt';
push @{ $attr->{join} }, 'mc';
$attr->{prefetch} = 'mc';
my $rs1 = $c->model('weight::Mdata')->search($where, $attr);


HTH

    patrick

-- 
Patrick Meidl, Mag.
Senior Expert Software Engineering

IST - Institute of Science and Technology Austria
Am Campus 1
A-3400 Klosterneuburg, Austria

R 03.EG.003
T +43 2243 9000 1063
E pmeidl at ist.ac.at
W http://www.ist.ac.at/




More information about the DBIx-Class mailing list