[Dbix-class] Constructing "WHERE" clause in DBIx
Rob Kinyon
rob.kinyon at gmail.com
Tue Aug 11 01:57:00 GMT 2009
On Mon, Aug 10, 2009 at 19:42, Eric Wee<EWee at au.westfield.com> wrote:
> $c->model(DB::Client)->search(
> {
> is_retail => '1',
> enabled_date => { '!=' => undef },
> enabled_date => { '<' => 'NOW' },
> };
>
> Not sure how to construct it with ..
>
>> AND (disabled_date is null
>> OR disabled_date < enabled_date
>> OR disabled_date > now())
This should do the trick. Peter will chime in with corrections as needed.
->search({
is_retail => '1',
enabled_date => { '!=' => undef },
enabled_date => { '<' => \'NOW()' },
-and => {
-or => {
disabled_date => undef,
disabled_date => { '<' => 'enabled_date' },
disabled_date => { '>' => \'NOW()', }
},
},
});
The scalarref is important for NOW() otherwise it won't work.
Rob
More information about the DBIx-Class
mailing list