-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Hi,
If I write these three lines of code in a file in the examples directory :
require_once dirname(__FILE__) . '/../src/PHPSQLParser.php';
$sql = "SELECT REPLACE(NOW(), '-', '')";
$parser = new PHPSQLParser($sql, true);
It fails with this error :
Warning: Invalid argument supplied for foreach() in
/Users/nico/Downloads/PHP-SQL-Parser/src/processors/InsertProcessor.php on line
51
Warning: strpos(): Empty needle in
/Users/nico/Downloads/PHP-SQL-Parser/src/positions/PositionCalculator.php on
line 80
Fatal error: Uncaught exception 'UnableToCalculatePositionException' with
message 'cannot calculate position of within (NOW(), '-', '')' in
/Users/nico/Downloads/
PHP-SQL-Parser/src/positions/PositionCalculator.php:199
Stack trace:
#0
/Users/nico/Downloads/PHP-SQL-Parser/src/positions/PositionCalculator.php(215):
PositionCalculator->lookForBaseExpression('SELECT REPLACE(...', 14, Array, 0, Ar
ray)
#1
/Users/nico/Downloads/PHP-SQL-Parser/src/positions/PositionCalculator.php(215):
PositionCalculator->lookForBaseExpression('SELECT REPLACE(...', 14, Array, 'REPL
ACE', Array)
#2
/Users/nico/Downloads/PHP-SQL-Parser/src/positions/PositionCalculator.php(70):
PositionCalculator->lookForBaseExpression('SELECT REPLACE(...', 14, Array, 0,
Arr
ay)
#3 /Users/nico/Downloads/PHP-SQL-Parser/src/PHPSQLParser.php(90):
PositionCalculator->setPositionsWithinSQL('SELECT REPLACE(...', Array)
#4 /Users/nico/Downloads/PHP-SQL-Parser/src/PHPSQLParser.php(65):
PHPSQLParser->parse('SELECT REPLACE(...', true)
#5 /Users/nico/Downloads/PHP-SQL-Parser/exa in
/Users/nico/Downloads/PHP-SQL-Parser/src/positions/PositionCalculator.php on
line 199
shell returned 255
It seems that for this query 'REPLACE' is considered as the keyword and not the
function name.
What version of the product are you using? On what operating system?
php-sql-parser-20140108.zip on a mac.
thank you,
Nicolas
Original issue reported on code.google.com by nderm...@adequasys.com on 28 Aug 2014 at 4:22
Reactions are currently unavailable