> On Sat, Jun 16, 2007 at 10:22:45PM -0700, Mike Henson wrote:
> > Hello,
> > 
> > If I call a relationship accessor are the resulting objects it
> produces
> > cached or is the query sent to the db every time?
> > 
> > Example:
> > 
> > =====
> > # Very basic relationship snippets
> > package Example::Shelf;
> > __PACKAGE__->table('shelf');
> > __PACKAGE__->belongs_to( 'books' => 'Example::Books' );
> 
> I think you wanted has_many there if its plural books.
> 
> The query will normally be re-run, but you can later the behaviour by
> doing (fixing your Books -> Book class naming error)
> 
> __PACKAGE__->has_many('books' => 'Example::Book', undef, { cache =>
> 1 });
> 
> Note that if you prefetched the books when grabbing your shelf
> object(s)
> this would happen automatically.

Thanks for working through my bad example. I missed the line in the pod
that says "In addition to standard result set attributes...".

Mike
-- 


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to