Skip to content

Commit 2bc0559

Browse files
committed
added ilike
1 parent 67f32c1 commit 2bc0559

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/Query/Postgresql/Ilike.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace DoctrineExtensions\Query\Postgresql;
4+
5+
use Doctrine\ORM\Query\AST\ASTException;
6+
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
7+
use Doctrine\ORM\Query\Lexer;
8+
use Doctrine\ORM\Query\AST\Node;
9+
use Doctrine\ORM\Query\Parser;
10+
use Doctrine\ORM\Query\QueryException;
11+
use Doctrine\ORM\Query\SqlWalker;
12+
13+
class Ilike extends FunctionNode
14+
{
15+
/** @var Node */
16+
protected $field;
17+
/** @var Node */
18+
protected $query;
19+
20+
/**
21+
* @param Parser $parser
22+
*
23+
* @throws QueryException
24+
*/
25+
public function parse(Parser $parser)
26+
{
27+
$parser->match(Lexer::T_IDENTIFIER);
28+
$parser->match(Lexer::T_OPEN_PARENTHESIS);
29+
$this->field = $parser->StringExpression();
30+
$parser->match(Lexer::T_COMMA);
31+
$this->query = $parser->StringExpression();
32+
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
33+
}
34+
35+
/**
36+
* @param SqlWalker $sqlWalker
37+
*
38+
* @return string
39+
* @throws ASTException
40+
*/
41+
public function getSql(SqlWalker $sqlWalker)
42+
{
43+
return '(' . $this->field->dispatch($sqlWalker) . ' ILIKE ' . $this->query->dispatch($sqlWalker) . ')';
44+
}
45+
}

0 commit comments

Comments
 (0)