[CDBI] essential fields not populating as expected

Bill Moseley moseley at hank.org
Tue May 1 04:02:52 BST 2007

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' ] },

Bill Moseley
moseley at hank.org

More information about the ClassDBI mailing list