greenlion / PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL
BSD 3-Clause "New" or "Revised" License
607 stars 156 forks source link

"strpos(): Empty needle" warning when SQL query refers to a `help` table #320

Open nicoder opened 4 years ago

nicoder commented 4 years ago

hi,

when running this code example:

<?php

namespace PHPSQLParser;
require_once dirname(__FILE__) . '/../vendor/autoload.php';

$sql = 'SELECT * from help';
echo $sql . "\n";
try {
    $parser = new PHPSQLParser($sql, true);
} catch (\Exception $e) {
    echo "caught";
}

the following PHP warning is displayed:

Warning: strpos(): Empty needle in src/PHPSQLParser/positions/PositionCalculator.php on line 138

Ideally the library would be able to parse such a query since MySQL can.

Alternatively it would be nice to avoid the warning.