/** * Filter field with `LIKE`. * * @param string $filterName * @param string $field */ protected function likeFilter($filterName, $field) { $info = $this->extract($filterName); $info['values'] = explode(',', str_replace('*', '%', $info['values'])); foreach ($info['values'] as $value) { if ($info['cond']) { $expr = $this->expr->like($field, "'%{$value}%'"); } else { $expr = $this->expr->notLike($field, "'%{$value}%'"); } } $this->builder->andWhere($expr); $this->filters[$filterName] = $info; }
/** * Creates a NOT LIKE() comparison expression with the given arguments. * * @param string $x Field in string format to be inspected by NOT LIKE() comparison. * @param mixed $y Argument to be used in NOT LIKE() comparison. * * @return string */ public function notLike($x, $y) { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnName($y); return $this->expressionBuilder->notLike($x, $y); }
/** * @dataProvider dataLike * * @param mixed $input * @param bool $isLiteral */ public function testNotLike($input, $isLiteral) { list($doctrineInput, $ocInput) = $this->helpWithLiteral($input, $isLiteral); $this->assertEquals($this->doctrineExpressionBuilder->notLike('`test`', $doctrineInput), $this->expressionBuilder->notLike('test', $ocInput)); }