Thanks to all for help and explanation as to why so.
 
I liked the below solution the best. thx again.
 
 
 


________________________________
From: Dagfinn Ilmari Mannsåker <ilm...@ilmari.org>
To: dbix-class@lists.scsys.co.uk 
Sent: Monday, January 21, 2013 4:34 AM
Subject: [Dbix-class] Re: help needed in forming a 'and' and 'or' select query 
using DBIx::Class

Michele Beltrame <m...@cattlegrid.info> writes:

> Hello!
>
>> columnA = x AND ( columnB = zz OR columnB LIKE '%mm%' )
>
> It should be like this:
>
> $val = 'mm';
> $my_rs = $schema->resultset('Mytable')->search({
>              columnA => 'x',
>              -or => [
>                      columnB => 'zz',
>                      columnB => { like => '%'.$val.'%' }
>              ],
> });

Or a slightly more concise version:

my $rs = $schema->resultset('MyTable')->search({
    columnA => 'x',
    columnB => [ 'zz', { like => '%'.$val'%' } ],
});


-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of."                              -- Skud's Meta-Law


_______________________________________________
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
_______________________________________________
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