I also tried adding:
\'item.title AS item_title'
to my select portion but that didn't work either (Can't locate object
method "item_title")
On Jan 27, 2007, at 3:03 AM, Peter Edwards wrote:
So you have watching -> persons -> relations -> itemsDoes $thing->person->relation->item->title work from the prefetched data ifyou turn DBIC_TRACE on? Regards, Peter -----Original Message----- From: Christopher Heschong [mailto:[EMAIL PROTECTED] Sent: 27 January 2007 02:53 To: [email protected] Subject: [Dbix-class] accessing columns in multi-step prefetches So I have this code: my $rs = $self->search_related('watching', {}, { select => [ { distinct => 'item.id' } ], prefetch => { person => { relations => 'item' } }, join => { 'person' => { 'relations' => 'item' } }, order_by => 'item.releasedate DESC', page => 1, rows => $count } ); $thing = $rs->first; Which produces this SQL on trace: SELECT DISTINCT( item.id ), person.id, person.mtime, person.title, person.photo, person.refresh, relations.person, relations.item, relations.role, item.id, item.mtime, item.title, item.releasedate, item.type, item.manufacturer, item.asin, item.itms, item.photo, item.universal FROM watching me JOIN persons person ON ( person.id = me.person ) LEFT JOIN relations relations ON ( relations.person = person.id ) JOIN items item ON ( item.id = relations.item ) WHERE ( me.user = ? ) ORDER BY item.releasedate DESC, relations.person LIMIT 1: '1' What I can't figure out is how to display the 'item.title' field from the $thing object. All the person.* things are available, but not item.* $thing->person->title; # works $thing->item->title; # Can't locate object method "item" Do I need to do something different with my prefetch definition to get DBIx::Class to notice that I fetched the items table? Thanks! _______________________________________________ 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/dbix- [EMAIL PROTECTED]/
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]/
