您好我想使用DBix :: Class从数据库中获取唯一(不同)值,但无法使用我当前的搜索方法找到该方法:
my $rs = $schema->resultset('DiscreteCalendar')->search(
{
holidaytype => 'W',
branchcode => $branchcode,
},
{
select => [{ DAYOFWEEK => 'date' }],
as => [qw/ weekday /],
where => \['date between ? and ?',$today, $endDate ],
}
);
感谢您的帮助!
答案 0 :(得分:2)
您应该只需将第二个哈希中的distinct => 1
添加到search
函数中,例如:
my $rs = $schema->resultset('DiscreteCalendar')->search(
{
holidaytype => 'W',
branchcode => $branchcode,
},
{
distinct => 1,
select => [{ DAYOFWEEK => 'date' }],
as => [qw/ weekday /],
where => \['date between ? and ?',$today, $endDate ],
}
);