/** * {@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); } }
/** * Creates a non equality comparison expression with the given arguments. * First argument is considered the left expression and the second is the right expression. * When converted to string, it will generated a <left expr> <> <right expr>. Example: * * [php] * // u.id <> 1 * $q->where($q->expr()->neq('u.id', '1')); * * @param mixed $x The left expression. * @param mixed $y The right expression. * * @return string */ public function neq($x, $y) { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnName($y); return $this->expressionBuilder->neq($x, $y); }
/** * @dataProvider dataComparisons * * @param mixed $input1 * @param bool $isInput1Literal * @param mixed $input2 * @param bool $isInput2Literal */ public function testNotEquals($input1, $isInput1Literal, $input2, $isInput2Literal) { list($doctrineInput1, $ocInput1) = $this->helpWithLiteral($input1, $isInput1Literal); list($doctrineInput2, $ocInput2) = $this->helpWithLiteral($input2, $isInput2Literal); $this->assertEquals($this->doctrineExpressionBuilder->neq($doctrineInput1, $doctrineInput2), $this->expressionBuilder->neq($ocInput1, $ocInput2)); }