Skip to content

Commit

Permalink
Merge pull request #291 from jaiminmoslake7020/master
Browse files Browse the repository at this point in the history
UNION with function causes array index error.
  • Loading branch information
greenlion committed Dec 23, 2018
2 parents 1a4ee5b + 371065a commit 8b73e66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PHPSQLParser/processors/BracketProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public function process($tokens) {

private function getRemainingNotBracketExpression($subtree)
{
// https://github.com/greenlion/PHP-SQL-Parser/issues/279
// https://github.com/sinri/PHP-SQL-Parser/commit/eac592a0e19f1df6f420af3777a6d5504837faa7
// as there is no pull request for 279 by the user. His solution works and tested.
if (empty($subtree)) $subtree = array();// as a fix by Sinri 20180528
$remainingExpressions = array();
$ignoredKeys = array('BRACKET', 'SELECT', 'FROM');
$subtreeKeys = array_keys($subtree);
Expand Down
4 changes: 4 additions & 0 deletions src/PHPSQLParser/processors/SQLProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function process($tokens) {
$tokenCount = count($tokens);
for ($tokenNumber = 0; $tokenNumber < $tokenCount; ++$tokenNumber) {

// https://github.com/greenlion/PHP-SQL-Parser/issues/279
// https://github.com/sinri/PHP-SQL-Parser/commit/eac592a0e19f1df6f420af3777a6d5504837faa7
// as there is no pull request for 279 by the user. His solution works and tested.
if (!isset($tokens[$tokenNumber])) continue;// as a fix by Sinri 20180528
$token = $tokens[$tokenNumber];
$trim = trim($token); // this removes also \n and \t!

Expand Down

0 comments on commit 8b73e66

Please sign in to comment.