Skip to content

Commit 38444dc

Browse files
committed
Fix bind parameter in LIMIT OFFSET
- Fixes #498 Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 349a811 commit 38444dc

File tree

2 files changed

+12
-31
lines changed

2 files changed

+12
-31
lines changed

src/Components/Limit.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ class Limit extends Component
1919
/**
2020
* The number of rows skipped.
2121
*
22-
* @var int
22+
* @var int|string
2323
*/
2424
public $offset;
2525

2626
/**
2727
* The number of rows to be returned.
2828
*
29-
* @var int
29+
* @var int|string
3030
*/
3131
public $rowCount;
3232

3333
/**
34-
* @param int $rowCount the row count
35-
* @param int $offset the offset
34+
* @param int|string $rowCount the row count
35+
* @param int|string $offset the offset
3636
*/
3737
public function __construct($rowCount = 0, $offset = 0)
3838
{
@@ -88,8 +88,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
8888
continue;
8989
}
9090

91-
// Skip if not a number
92-
if (($token->type !== Token::TYPE_NUMBER)) {
91+
// Skip if not a number or a bind parameter (?)
92+
if (
93+
! ($token->type === Token::TYPE_NUMBER
94+
|| ($token->type === Token::TYPE_SYMBOL && ($token->flags & Token::FLAG_SYMBOL_PARAMETER)))
95+
) {
9396
break;
9497
}
9598

tests/data/bugs/gh498.out

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@
346346
"order": null,
347347
"limit": {
348348
"@type": "PhpMyAdmin\\SqlParser\\Components\\Limit",
349-
"offset": 0,
350-
"rowCount": 0
349+
"offset": "?",
350+
"rowCount": "?"
351351
},
352352
"procedure": null,
353353
"into": null,
@@ -396,28 +396,6 @@
396396
},
397397
"errors": {
398398
"lexer": [],
399-
"parser": [
400-
[
401-
"Unexpected token.",
402-
{
403-
"@type": "@28"
404-
},
405-
0
406-
],
407-
[
408-
"Unrecognized keyword.",
409-
{
410-
"@type": "@30"
411-
},
412-
0
413-
],
414-
[
415-
"Unexpected token.",
416-
{
417-
"@type": "@32"
418-
},
419-
0
420-
]
421-
]
399+
"parser": []
422400
}
423401
}

0 commit comments

Comments
 (0)