On 6/24/06, Matt S Trout <[EMAIL PROTECTED]> wrote:
> Tim Watson wrote:
> > I think I was going about this a little reverse...
> >
> > This works...
> >
> > my $rs = $dbh->resultset('User')->search({ 'sessionid' => '123456'
> > } ,{ prefetch => 'user_session' });
> >
> > But I am unable to figure out how to access anything else in that
> > session row... since I am returned a user object by $rs->next;
> >
> > I would like to be able to get a session obect and the user object
> > from that one line..
>
> Oh, actually you're going to end up with a resultset of session objects that
> way. What you want is
>
> my $rs = $dbh->resultset('Session')->search({ 'sessionid' => '123456' }, {
> prefetch => 'user' });
>
> then $rs->next will return a $session object with $session->user already
> populated with the appropriate user object
>
That doesn't work... it gives me the relationship error...
DBIx::Class::ResultSet::search(): No such relationship user
This does work... although it doesn't look that pretty so I'm going to
assume its still not the easiest way...
my $rs = $dbh->resultset('User')->search({ 'sessionid' => '123456'
} ,{ prefetch => 'user_session' });
my $user = $rs->next;
print "u " . $user->username . "\n";
my $session = $user->user_session->next;
print "s ". $session->sessionid . "\n";
_______________________________________________
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]/