1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\ORM\Query\AST\Functions;
/**
* "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")"
*
* @author robo
*/
class SubstringFunction extends FunctionNode
{
private $_stringPrimary;
private $_firstSimpleArithmeticExpression;
private $_secondSimpleArithmeticExpression;
public function geStringPrimary()
{
return $this->_stringPrimary;
}
public function getSecondSimpleArithmeticExpression()
{
return $this->_secondSimpleArithmeticExpression;
}
public function getFirstSimpleArithmeticExpression()
{
return $this->_firstSimpleArithmeticExpression;
}
/**
* @override
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
//TODO: Use platform to get SQL
$sql = 'SUBSTRING(' .
$sqlWalker->walkStringPrimary($this->_stringPrimary)
. ', ' .
$sqlWalker->walkSimpleArithmeticExpression($this->_firstSimpleArithmeticExpression)
. ', ' .
$sqlWalker->walkSimpleArithmeticExpression($this->_secondSimpleArithmeticExpression)
. ')';
return $sql;
}
/**
* @override
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match($lexer->lookahead['value']);
$parser->match('(');
$this->_stringPrimary = $parser->StringPrimary();
$parser->match(',');
$this->_firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
$parser->match(',');
$this->_secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
$parser->match(')');
}
}