[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] DBIx::Class (SQL::Abstract)
Is it scary that I'm getting used to this stuff now?
Jay Hannah
Software Architect
jhannah@mutationgrid.com | http://mutationgrid.com | 1-402-598-7782
Catalyst action snippet:
while (++$i) {
my $skill = $c->req->param("skill_id_$i");
my $score = $c->req->param("score_id_$i");
last unless ($skill);
last if ($skill =~ /^-- /);
push @where_skills, {
skill_id => $skill,
score => { '>=', $score },
};
}
my $where = {
active => 1,
-or => [ @where_skills ],
};
$c->log->debug(Dumper($where));
$search = $c->model('DB::Rating')->search($where);
The Dumper output:
'-or' => [
{
'skill_id' => '71',
'score' => {
'>=' => '0'
}
},
{
'skill_id' => '70',
'score' => {
'>=' => '0'
}
},
{
'skill_id' => '74',
'score' => {
'>=' => '0'
}
}
],
'active' => 1
The SQL search() runs:
SELECT me.id, me.person_id, me.skill_id, me.rater_id, me.score, me.active, me.date_created, me.date_updated FROM rating me WHERE ( ( ( ( score >= ? AND skill_id = ? ) OR ( score >= ? AND skill_id = ? ) OR ( score >= ? AND skill_id = ? ) ) AND active = ? ) ): '0', '71', '0', '70', '0', '74', '1'
tee-hee! :)