PHP-SQL-Parser icon indicating copy to clipboard operation
PHP-SQL-Parser copied to clipboard

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

Open nicoder opened this issue 5 years ago • 0 comments

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.

nicoder avatar Jun 17 '20 14:06 nicoder