/** * {@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); } }
/** * 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; }
/** * Creates a IN () comparison expression with the given arguments. * * @param string $x The field in string format to be inspected by IN() comparison. * @param string|array $y The placeholder or the array of values to be used by IN() comparison. * * @return string */ public function in($x, $y) { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnNames($y); return $this->expressionBuilder->in($x, $y); }
/** * @dataProvider dataIn * * @param mixed $input * @param bool $isLiteral */ public function testIn($input, $isLiteral) { list($doctrineInput, $ocInput) = $this->helpWithLiteral($input, $isLiteral); $this->assertEquals($this->doctrineExpressionBuilder->in('`test`', $doctrineInput), $this->expressionBuilder->in('test', $ocInput)); }