/**
  * {@inheritdoc}
  */
 protected function doWalkComparison($fieldName, $operator, $placeholder)
 {
     switch ($operator) {
         case Comparison::IN:
             return $this->expr->in($fieldName, $placeholder);
         case Comparison::NIN:
             return $this->expr->notIn($fieldName, $placeholder);
         case Comparison::EQ:
         case Comparison::IS:
             if ($placeholder === null) {
                 return $this->expr->isNull($fieldName);
             }
             return $this->expr->eq($fieldName, $placeholder);
         case Comparison::NEQ:
             if ($placeholder === null) {
                 return $this->expr->isNotNull($fieldName);
             }
             return $this->expr->neq($fieldName, $placeholder);
         case Comparison::CONTAINS:
             return $this->expr->like($fieldName, $placeholder);
         default:
             $operator = self::convertComparisonOperator($operator);
             if ($operator) {
                 return $this->expr->comparison($fieldName, $operator, $placeholder);
             }
             throw new \RuntimeException("Unknown comparison operator: " . $operator);
     }
 }
Пример #2
0
 /**
  * Filter field with `IN`.
  *
  * @param string $filterName
  * @param string $field
  */
 protected function filterIn($filterName, $field)
 {
     $info = $this->extract($filterName);
     $info['values'] = explode(',', $info['values']);
     $values = array_map([$this, 'quote'], $info['values']);
     if ($info['cond']) {
         $expr = $this->expr->in($field, $values);
     } else {
         $expr = $this->expr->notIn($field, $values);
     }
     $this->builder->andWhere($expr);
     $this->filters[$filterName] = $info;
 }
Пример #3
0
 /**
  * Creates a NOT IN () comparison expression with the given arguments.
  *
  * @param string $x The field in string format to be inspected by NOT IN() comparison.
  * @param string|array $y The placeholder or the array of values to be used by NOT IN() comparison.
  *
  * @return string
  */
 public function notIn($x, $y)
 {
     $x = $this->helper->quoteColumnName($x);
     $y = $this->helper->quoteColumnNames($y);
     return $this->expressionBuilder->notIn($x, $y);
 }
Пример #4
0
 /**
  * @dataProvider dataIn
  *
  * @param mixed $input
  * @param bool $isLiteral
  */
 public function testNotIn($input, $isLiteral)
 {
     list($doctrineInput, $ocInput) = $this->helpWithLiteral($input, $isLiteral);
     $this->assertEquals($this->doctrineExpressionBuilder->notIn('`test`', $doctrineInput), $this->expressionBuilder->notIn('test', $ocInput));
 }