[Dbix-class] How to create a row object that contains related objects in DBIx::Class?

Jan Grmela jan.grmela at imakers.cz
Thu Aug 16 07:42:50 GMT 2012


Hi Eugene,
I'm pretty sure this should help you:
http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#cache

2012/8/16 Eugene Yarmash <e.yarmash at gmail.com>:
> Hello and thank you to everyone who takes part in the development of
> DBIx::Class. I have a question (also posted at SO
> http://stackoverflow.com/q/11970939/244297).
>
> When you create a Row object in DBIx::Class you can pass related objects as
> values, e.g.
>
> my $author = $authors_rs->find(1);
> my $book = $books_rs->create({ author => $author, title => 'title' });
>
> However, if you later use the author accessor, the object is retrieved again
> from the database. Is it possible to create an object so that the related
> object can be accessed without the additional query?
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



-- 
Jan Grmela
jan.grmela at imakers.cz
+420 608 110 686

iMakers, s.r.o.
Absolonova 725/81, Brno, 62400, Czech Republic

ICO/Id: 29228875
DIC/VAT No: CZ29228875



More information about the DBIx-Class mailing list