3
3
4
4
use Vimeo \MysqlEngine \TokenType ;
5
5
use Vimeo \MysqlEngine \Query \Expression \ConstantExpression ;
6
- use Vimeo \MysqlEngine \Query \Expression \ParameterExpression ;
6
+ use Vimeo \MysqlEngine \Query \Expression \NamedPlaceholderExpression ;
7
+ use Vimeo \MysqlEngine \Query \Expression \QuestionMarkPlaceholderExpression ;
7
8
use Vimeo \MysqlEngine \Query \LimitClause ;
8
9
9
10
final class LimitParser
@@ -45,7 +46,13 @@ public function parse()
45
46
if ($ next ->type === TokenType::NUMERIC_CONSTANT ) {
46
47
$ limit = new ConstantExpression ($ next );
47
48
} elseif ($ next ->type === TokenType::IDENTIFIER && $ next ->value === '? ' ) {
48
- $ limit = new ParameterExpression ($ next , $ next ->parameterName );
49
+ if ($ next ->parameterOffset !== null ) {
50
+ $ limit = new QuestionMarkPlaceholderExpression ($ next , $ next ->parameterOffset );
51
+ } elseif ($ next ->parameterName !== null ) {
52
+ $ limit = new NamedPlaceholderExpression ($ next , $ next ->parameterName );
53
+ } else {
54
+ throw new ParserException ('? encountered with unknown offset ' );
55
+ }
49
56
} else {
50
57
throw new ParserException ("Expected integer or parameter after OFFSET " );
51
58
}
@@ -64,7 +71,7 @@ public function parse()
64
71
if ($ next ->type === TokenType::NUMERIC_CONSTANT ) {
65
72
$ offset = new ConstantExpression ($ next );
66
73
} elseif ($ next ->type === TokenType::IDENTIFIER && $ next ->value === '? ' ) {
67
- $ offset = new ParameterExpression ($ next , $ next ->parameterName );
74
+ $ offset = new NamedPlaceholderExpression ($ next , $ next ->parameterName );
68
75
} else {
69
76
throw new ParserException ("Expected integer or parameter after OFFSET " );
70
77
}
@@ -81,7 +88,7 @@ public function parse()
81
88
if ($ next ->type === TokenType::NUMERIC_CONSTANT ) {
82
89
$ limit = new ConstantExpression ($ next );
83
90
} elseif ($ next ->type === TokenType::IDENTIFIER && $ next ->value === '? ' ) {
84
- $ limit = new ParameterExpression ($ next , $ next ->parameterName );
91
+ $ limit = new NamedPlaceholderExpression ($ next , $ next ->parameterName );
85
92
} else {
86
93
throw new ParserException ("Expected integer or parameter after OFFSET " );
87
94
}
0 commit comments