[CDBI] Preloading objects when using a view

Perrin Harkins perrin at elem.com
Wed Mar 29 01:27:19 BST 2006

On Tue, 2006-03-28 at 16:10 -0800, Bill Moseley wrote:
> Now, say, the view also returns the artist name.  What I'd like to do
> is have CDBI populate the "name" column of the artist object it
> created as a result of the search on the view class.  That way I'd
> avoid a second trip to the database.

Do you fetch the view object with retrieve()?  You could probably
override that and hard-code the filling in of the name.  Or you could
override something internal in this class, like construct().

> It would be nice to do something like:
>     __PACKAGE__->has_a( artist_name => ['Music::Artist', 'name' ] );
> Anyone doing something like this?

I'd probably just switch to Rose::DB::Object rather than trying to build
this into CDBI, but I can see why that would be a non-starter if you
have a big codebase here.

- Perrin

More information about the ClassDBI mailing list