[Dbix-class] trouble with relationships

Lee Standen nom at standen.id.au
Fri Nov 3 06:53:01 GMT 2006


my @all_user_notes =
$schema->resultset('User')->search( username => $username )->notes;

Easier, if you've already got the user object instantiated.
my @all_user_notes = $user->notes;

I think that does (a lot more simply) what you want.





Devin Austin wrote:
> I'm using this code to attempt to retrieve a related table's info:
> my @all_user_notes = $user_notes->search_related('notes',
>         {
>             username => $session->param('username')
>         }
>     );
>     my @user_notes = map {
>         {
>             'noteid'    => $_->noteid,
>             'number'    => $_->number,
>             'date'      => $_->date,
>             'private'   => $_->private,
>         }
>     } @all_user_notes;
> 
> And I'm getting this when I run Data::Dumper on @user_notes:
> 
> $VAR1 = {
>           'number' => undef,
> 
>           'date' => undef,
>           'private' => undef,
>           'noteid' => undef
>         };
> 
> Why would all my fields be coming up empty?
> 
> -- 
> timorperfectus.com <http://timorperfectus.com> - web design to 
> frightening perfection.
> 
> 
> One last song
> Given to an Angel's Son
> As soon as you were gone
> As soon as you were gone
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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-class@lists.rawmode.org/



More information about the Dbix-class mailing list