[Catalyst] $c->user->some_relationship always retrives user id
from the db
Mitchell Jackson
mitch.lists at onsitesquad.com
Wed Feb 13 20:33:18 GMT 2008
You don't have to do queries using relationship behavior if you don't
like the way it works. For example:
$user_id = $c->session->{user_id};
@albums = $c->model('albums')->search({ user_id => $user_id });
Mitch
Moritz Onken wrote:
> Hi,
>
> I request all albums of a user by calling $c->user->albums->all;
> That results in a query which retrieves the user id and then querys
> the album table with that user id in the where clause.
>
> It works, but how can I prevent that first query which retrieves the
> user id? Can't I store the user id in the session so that the query
> could use that value instead of receiving it from the database?
>
> I looked through the docs but couldn't find anythink. I hope this is
> the right place to ask.
>
> Thanks in advance,
>
> moritz
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
More information about the Catalyst
mailing list