Wolfgang Kinkeldei wrote:
Hello <linuxsupport>,
looks like nobody answered before...
You will find an answer to your questions if you carefully read the
documentation in
- DBIx::Class::Manual::Joining
- DBIx::Class::Manual::Cookbook
To give a short answer, you should never use "join" and "prefetch" in the same
query, these options are mutually exclusive.
^^ this is incorrect, which document claims this?
If you choose to use "join" your result will have as many rows as your SQL statement retrieves. You will need to add extra "select" or
"+select" options paired with "as" or "+as" entries to get the column values from your related tables. Please keep in mind that no
extra accessors for "as" / "+as" generated columns will be generated. You must fetch these values via
"$result->get_column('name_of_the_column')".
This is also more than half-incorrect
On the other hand, if you use "prefetch", your resultset will only have the
number of rows, that are distinct in the main table of your query. Then, you can access
all prefetched tables using their accessor methods. In contrast to a joined DBIx-Query
this will not trigger additional SQL fired to your database, as the joined tables' data
has already been read. Prefetch by convention always reads every column in all tables
used in the query.
This otoh is indeed correct.
Please join us in channel #dbix-class on irc.perl.org so we can clear
up the confusion and guide you towards improving the docs (the core
authors do not really see ambiguities in documentation as they just
know which piece does what inside out).
Cheers!
_______________________________________________
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]