Hi there Moritz,
The select by id that you are seeing is the retrieval of the user from
the database when first recovering the user from the session. I am
assuming that you are using the
Catalyst::Authentication::Store::DBIx::Class storage module. Any
access to $c->user will trigger this query. It is, however, only done
once per request.
In short - if you are going to be using $c->user in any way during the
request, that find by id will be done at some point. So going out of
your way to avoid it only makes sense if you are sure you will not use
any other user information during the request.
Jay
On Feb 13, 2008, at 1:33 PM, Mitchell Jackson wrote:
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: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/
---
"May we not return to those scoundrels of old, the illustrious
founders of superstition and fanaticism, who first took the knife from
the altar to make victims of those who refused to be their disciples."
- Voltaire
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/