chenster / 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 FROM clause is absent #81

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Some SQL queries do not have a table / from clause. The parser works fine, the 
creator assumes the FROM clause will always be present.

$parser = new PHPSQLParser;
$parsed = $parser->parse('SELECT NOW()');
$creator = new PHPSQLCreator();
print $creator->create($parsed);

What is the expected output? What do you see instead?
Expected "SELECT NOW()", Got undefined index 'FROM'

Simple fix to change processSelectStatement:71
from:
$sql = $this->processSELECT($parsed['SELECT']) . " " . 
$this->processFROM($parsed['FROM']);
to:
            $sql = $this->processSELECT($parsed['SELECT']);
            if (isset($parsed['FROM'])) {
                $sql .= " " . $this->processFROM($parsed['FROM']);
            }

Original issue reported on code.google.com by cag...@gmail.com on 12 Dec 2012 at 12:22

GoogleCodeExporter commented 8 years ago
I think, this issue has been solved. Check r379.

Original comment by pho...@gmx.de on 24 Oct 2013 at 9:43