Skip to content

Re-formating LIMIT destroys DELETE and UPDATE queries #252

Open
@werner-freytag

Description

@werner-freytag

When building queries, the LIMIT is re-formatted. For example SELECT * FROM tbl LIMIT 1 is changed to SELECT * FROM tbl LIMIT 0, 1. This works just fine for SELECT queries, but not for DELETE or UPDATE queries.

Example:

$query1 = "DELETE FROM a LIMIT 1";
$parser = new PhpMyAdmin\SqlParser\Parser($query1);
$statement = $parser->statements[0];

$table2 = new \PhpMyAdmin\SqlParser\Components\Expression("", "b", "", "");
$statement->from[0] = $table2;

echo $statement->build();

results in

DELETE  FROM `b` LIMIT 0, 1

The changed query fails, while the original query is perfect SQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions