The parser may not well deal with the comments.
Here is an example, as it treat -- as a part of table alias.
Give sql as
SELECT * FROM ecshop.ecs_order_info
-- LIMIT 0, 30
--
process by PhpMyAdmin\SqlParser\Parser
object(PhpMyAdmin\SqlParser\Statements\SelectStatement)#28 (16) {
["expr"]=>
array(1) {
[0]=>
object(PhpMyAdmin\SqlParser\Components\Expression)#13 (7) {
["database"]=>
NULL
["table"]=>
NULL
["column"]=>
NULL
["expr"]=>
string(1) "*"
["alias"]=>
NULL
["function"]=>
NULL
["subquery"]=>
NULL
}
}
["from"]=>
array(1) {
[0]=>
object(PhpMyAdmin\SqlParser\Components\Expression)#11 (7) {
["database"]=>
string(6) "ecshop"
["table"]=>
string(14) "ecs_order_info"
["column"]=>
NULL
["expr"]=>
string(23) "ecshop.ecs_order_info--"
["alias"]=>
NULL
["function"]=>
NULL
["subquery"]=>
NULL
}
}
["partition"]=>
NULL
["where"]=>
NULL
["group"]=>
NULL
["having"]=>
NULL
["order"]=>
NULL
["limit"]=>
object(PhpMyAdmin\SqlParser\Components\Limit)#27 (2) {
["offset"]=>
int(0)
["rowCount"]=>
int(30)
}
["procedure"]=>
NULL
["into"]=>
NULL
["join"]=>
NULL
["union"]=>
array(0) {
}
["end_options"]=>
NULL
["options"]=>
object(PhpMyAdmin\SqlParser\Components\OptionsArray)#30 (1) {
["options"]=>
array(0) {
}
}
["first"]=>
int(0)
["last"]=>
int(12)
}
and rebuild after ensuring the limit expression is appended (by check the statement->limit property, and add it if lack), would get
SELECT * FROM ecshop.ecs_order_info-- LIMIT 0, 30
The parser may not well deal with the comments.
Here is an example, as it treat
--as a part of table alias.Give sql as
process by PhpMyAdmin\SqlParser\Parser
and rebuild after ensuring the limit expression is appended (by check the statement->limit property, and add it if lack), would get