예제 #1
0
 /**
  * @return FilterCondition
  */
 public static function group()
 {
     $group = new FilterCondition(self::GROUP);
     foreach (func_get_args() as $oArg) {
         $group->addCondition($oArg);
     }
     return $group;
 }
 /**
  * If you have a pseudo-property which maps to multiple real columns
  * then you can use this method to compile the condition
  * Only EQUALS or LIKE can be used with grouped columns
  *
  * @param FilterCondition $condition
  * @param string[]        $mappedProperties
  *
  * @return string
  *
  * @throws InvalidArgumentException
  */
 protected function _compileTextGroupCondition(FilterCondition $condition, array $mappedProperties)
 {
     // We'll allow equals or like for this condition
     if (!($condition->isEquals() || $condition->isLike())) {
         throw new InvalidArgumentException('Group filters only allowed with EQUALS or LIKE');
     }
     $value = $condition->getValue();
     $where = ' (';
     $or = '';
     foreach ($mappedProperties as $property) {
         if ($condition->isEquals()) {
             $where .= $or . $property . '=' . $this->pushParameter($value);
         } else {
             $where .= $or . $property . ' LIKE (' . $this->pushLikeParameter($value) . ')';
         }
         $or = ' OR ';
     }
     $where .= ') ';
     return $where;
 }
 /**
  * @param FilterCondition $condition
  * @param string          $mapped
  *
  * @return string
  *
  * @throws InvalidArgumentException
  */
 protected function compileMappedCondition(FilterCondition $condition, $mapped)
 {
     $value = $condition->getValue();
     $where = '';
     if ($condition->isLike()) {
         $where .= $this->compileLikeCondition($mapped, $value);
     }
     if ($condition->isEquals()) {
         $where .= $this->compileEqualsCondition($mapped, $value);
     }
     if ($condition->isGT()) {
         $where .= $this->compileScalarCondition($mapped, ' > ', $value);
     }
     if ($condition->isGTE()) {
         $where .= $this->compileScalarCondition($mapped, ' >= ', $value);
     }
     if ($condition->isLT()) {
         $where .= $this->compileScalarCondition($mapped, ' < ', $value);
     }
     if ($condition->isLTE()) {
         $where .= $this->compileScalarCondition($mapped, ' <= ', $value);
     }
     if ($condition->isIn()) {
         $where .= $this->compileInCondition($mapped, (array) $value);
     }
     return $where;
 }