Where clause examples - yuki-kimoto/DBIx-Custom GitHub Wiki
Create the following condition.
where price > 1500 and (title = 'Perl' or title = 'Ruby')Write the following code.
my $where = $dbi->where;
my $price = 1500;
my $titles = ['Perl', 'Ruby'];
my $clause = ['and',
'price > :price'
['or', ('title = :title') x @$titles],
];
my $param = {price => $price, title => $titles};
$where->clause($clause);
$where->param($param);Create the following condition
where date > '2010-01-01' and date < '2010-03-31'Write the following code.
my $where = $dbi->where;
my $start_date = '2010-01-01';
my $end_date = '2010-03-31';
my $clause = ['and', ':date{>}', ':date{<}'}];
my $param = {
date => [
$start_date // $dbi->not_exists,
$end_date // $dbi->not_exists
]
};
$where->clause($clause);
$where->param($param);