On 13 Aug 2010, at 15:39, Marc Perez wrote:
[Heavily edited down...]
> FIRST:
> package cmsDB::Files;
...
> __PACKAGE__->has_many(
> "fieldfiles",
> "cmsDB::Fieldfiles",
> { "foreign.file_id" => "self.file_id" },
> );
> When I try to access the fieldfiles data:
>
> while( my $file = $files->next() ) {
> print($file->fieldfiles->name)
> }
You are treating the fieldfiles relationship above as though it was a
belongs_to (or has_one) type relationship.
Instead $file->fieldfiles will return either a resultset of the
related rows (in scalar mode - which is what your example has),
or the matching rows in array mode, so you probably want:-
while( my $file = $files->next() ) {
print($_->name) foreach ($file->fieldfiles);
}
Nigel.
--
[ Nigel Metheringham [email protected] ]
[ - Comments in this message are my own and not ITO opinion/policy - ]
_______________________________________________
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/[email protected]