Re: [CDBI] essential fields not populating as expected
Bill Moseley <[email protected]> Mon, 30 Apr 2007 20:02:52 -0700
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Apr 30, 2007 at 05:32:57PM -0700, Jon Burdge wrote:
> What I'd really like is a way to create more than one object from each row,
> something like: "select b.*, a.* from b join a on b.a = a.aid" which would
> return a list of B objects with the A objects all preloaded from the same
> set of results. I haven't been able to find any examples on the wiki of
> anything like this, though.
Does Class::DBI::Sweet's prefetch option do what you want? In your
example I'd think you would need to do the search on Example::B since
it has_a "a".
my $b = Example::B->search(
{ bid => 1 },
{ prefetch => [ 'a' ] },
)->first;
--
Bill Moseley
[email protected]