Hi,

anyone can direct me on this please?

On Tue, Dec 28, 2010 at 4:32 PM, linuxsupport <[email protected]> wrote:

> Hi,
>
> I am trying to find best way to fetch data from multiple table using
> DBIx::Class relationship.
>
> I have 3 tables as follows.
>
> Articles ( id, title, sort_text) primary key => id
> ArticleAuthor (article_id, author_id) primary key => (article_id,
> author_id)
> Author (id, author_name) primary key => id
>
> Relationship.
>
> Article.pm
> has_many(article_author => "Article::Author", "article_id")
>
> ArticleAuthor.pm
> has_many(author => "Author", "id")
>
> I want to get title and sort_text from articles table and author_name form
> author table for a given id.
> I tried this
> $schema->resultset('Article)->search(
> {
>    id => '1'
> },
> { join => { article_author => author }
>   prefetch => { article_author => author }
> }
> );
>
> This returns me all the table filelds from all three table, I tried to put
> something columns => [qw/ title sort_text author_name/] but did not work.
>
> I want to know if above is correct way to use relationship? or is there a
> better way of doing the same?
> And how I can get only required columns.
>
> Thanks
>
_______________________________________________
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