On Fri, Sep 18, 2009 at 3:06 PM, Shawn Marincas
<shawngmarin...@gmail.com> wrote:
> I have a table Products and a table Tags with a many_to_many relationship
> setup, the purpose of which would be to easily generate a resultset of
> products with the given tag(s).  However, I'm running in to problems when I
> want to generate a resultset of product records filtered with multiple
> tags.  I was thinking that one of the following would work:
>
> my $tag1 = 'A';
> my $tag2 = 'B';

my $product_rs = $schema->resultset('Product')->search_rs({
    'tag.tag_id' => { -in => [qw/A B/] }
}, {
    join => { 'product_tags' => 'tag' }
});

> But apparently the many_to_many relationship accessor only returns a list of
> row_objects rather than a resultset itself, so I can't perform resultset
> searches on that.  So I tried the following to chain together two searches:

You've used the ->search method in your code in list context, so it
calls ->all over the resultset and returns a list of row objects.

-- 
     wallace reis/wreis         Catalyst and DBIx::Class consultancy with a clue
     Software Engineer          and a commit bit: 
http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
 http://www.shadowcat.co.uk     http://www.linkedin.com/in/wallacereis

_______________________________________________
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/dbix-class@lists.scsys.co.uk

Reply via email to