[Dbix-class] all data at once
Jason Gottshall
jgottshall at capwiz.com
Mon Dec 10 20:19:41 GMT 2007
Angel Kolev [mailto:ankolev at gmail.com] wrote:
> Thank you.
> It works, but only when prefetch only 1 table. If i try to do it with
both:
> my $rs = $c->model('AppModelDB::ClientFemale')->search(undef,
> {
> join
=> [qw/ client_family client_male /],
> prefetch
=> [qw/ client_family client_male /]
> });
> .. the result is:
>
> No such relationship client_male at
/usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 945
DBIx::Class::Schema::throw_exception('AppModelDB=HASH(0x927aab4)', 'No
such relationship client_male'................etc
> I only can use prefetch AppModelDB::ClientFemale -> client_family
andAppModelDB::ClientMale -> client_family. The relationships are
has_many and may_to_many. The "Family" table have
"_PACKAGE__->belongs_to" for both tables.
Your join and prefetch attributes must be nested hashrefs:
my $rs = $c->model('AppModelDB::ClientFemale')->search(undef,
{ join => { client_family => 'client_male' },
prefetch => { client_family => 'client_male' },
{
);
HTH,
Jason
More information about the DBIx-Class
mailing list