[Dbix-class] Re: help needed in forming a 'and' and 'or' select
query using DBIx::Class
Dagfinn Ilmari Mannsåker
ilmari at ilmari.org
Mon Jan 21 10:34:08 GMT 2013
Michele Beltrame <mb at 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
More information about the DBIx-Class
mailing list