sanjosh / php-sql-parser

Automatically exported from code.google.com/p/php-sql-parser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

PHPSQLCreator error when using insert into .. select ... #83

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
$parser = new PHPSQLParser("INSERT INTO newTablename (SELECT * FROM 
oldTablename);", true);
$creator = new PHPSQLCreator();
echo $creator->create($parser->parsed);

What is the expected output? What do you see instead?
Expected sql as shown above.
Instead error thrown:
Notice: Undefined index: VALUES in 
/home/wwwadmin/baseUpdate/php-sql-parser/php-sql-creator.php on line 89 
Warning: Invalid argument supplied for foreach() in 
/home/wwwadmin/baseUpdate/php-sql-parser/php-sql-creator.php on line 215
And result is: INSERT INTO newTablename (SELECT * FROM oldTablename) VALUES 

What version of the product are you using? On what operating system?
current (22.8.2012)

Please provide any additional information below.
This happens with all kind of statements, as long as they use insert into .. 
and select clause

Original issue reported on code.google.com by i...@enterprise-technologies.de on 13 Dec 2012 at 6:39

GoogleCodeExporter commented 8 years ago
The problem also exists while not using parenthesis:
$parser = new PHPSQLParser("INSERT INTO newTablename SELECT * FROM 
oldTablename;", true);
$creator = new PHPSQLCreator();
echo $creator->create($parser->parsed);

leads to: 
INSERT INTO newTablename
with message:
Notice: Undefined index: VALUES in 
/home/wwwadmin/baseUpdate/php-sql-parser/php-sql-creator.php on line 89 
Warning: Invalid argument supplied for foreach() in 
/home/wwwadmin/baseUpdate/php-sql-parser/php-sql-creator.php on line 215

Original comment by i...@enterprise-technologies.de on 14 Dec 2012 at 5:54

GoogleCodeExporter commented 8 years ago
This is a larger problem, because the parser doesn't split the SQL statement 
right. Within the creator code, you can also see a TODO within the 
processInsertStatement() method, which points to your issue :-)

Original comment by pho...@gmx.de on 23 Oct 2013 at 8:33

GoogleCodeExporter commented 8 years ago
I have changed the Creator for the new parser output. See r1017.

Original comment by pho...@gmx.de on 13 Jan 2014 at 12:06