Thanks Peter,

That means when I have to get columns from multiple tables I could use join
and select those column correct?
Or are you saying that I should not use join like this and use different
approach?
Basically I have to fetch data from multiple table to show one article.

That is why I posted here to find best way to retrieve data from multiple
related tables.

Thanks


On Fri, Dec 31, 2010 at 7:47 PM, Peter Rabbitson
<[email protected]<rabbit%[email protected]>
> wrote:

> linuxsupport wrote:
>
>> Thanks for the reply.
>>
>> I have something like
>>
>> my $rs = $schema->resultset('Article')->search(
>> {
>>   "me.id <http://me.id>" => 1
>>
>> },
>> {
>>    join => [
>>               {arti_author => "author"},
>>               {arti_comnt => "comments"},
>>              ],
>>     select => [
>>                 qw/ me.create_date author.author_name comments.comment
>> comments.comment_date comments.name <http://comments.name> /
>>
>>                  ],
>>       as => [
>>                  qw/ created author comment comment_date commented_by /
>>                 ]
>> }
>> );
>>         How can I use prefetch to simplify it?
>>
>>
> You can't - prefetch is something that you use when you need complete
> related (but distinct) result objects fetched at once. What you are doing
> instead is abandoning the strict separation and mixing data from several
> sources into one data object (which kinda defeats part of the purpose of
> DBIC). So no - you can not use prefetch here, as it has a different
> design endgoal.
>
> My advice is to stop thinking in SQL (I have N tables from which I retrieve
> M columns) and instead think in interrelated row objects. When you do in
> fact run across a bottleneck - we'll be happy to help you optimize a
> particular query, but doing what you show above as a general rule is
> largely
> missing the point of DBIC.
>
> Hope this helps, 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]
>
_______________________________________________
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]

Reply via email to