[Omaha.pm] DBIx::Class (SQL::Abstract)

Jay Hannah jhannah at mutationgrid.com
Thu May 12 18:00:06 PDT 2011


Is it scary that I'm getting used to this stuff now?

Jay Hannah
Software Architect
jhannah at 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!  :)


More information about the Omaha-pm mailing list