Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. please turn off debug print_r() 2. probbaly, some bug in parser triggers it #12

Closed
GoogleCodeExporter opened this issue Mar 23, 2016 · 3 comments

Comments

@GoogleCodeExporter
Copy link

WHAT STEPS WILL REPRODUCE THE PROBLEM?

1. $sql = "SELECT SQL_CALC_FOUND_ROWS SmTable.*, MATCH 
(SmTable.fulltextsearch_keyword) AGAINST ('google googles') AS keyword_score 
FROM SmTable WHERE SmTable.status = 'A' AND (SmTable.country_id = 1 AND 
SmTable.state_id = 10) AND MATCH (SmTable.fulltextsearch_keyword) AGAINST 
('google googles') ORDER BY SmTable.level DESC, keyword_score DESC LIMIT 0,10"

2. $parser = new PHPSQLParser($sql);


WHAT IS THE EXPECTED OUTPUT? WHAT DO YOU SEE INSTEAD?

No output expected.

Instead, it hits line 1242 and prints smth:
if(!is_array($processed)) {
    print_r($processed);   // 1242
    $processed = false;
}

What version of the product are you using? On what operating system?
http://php-sql-parser.googlecode.com/svn/trunk/php-sql-parser.php

uname -a
Linux ********* #1 SMP Tue Sep 1 10:25:30 EDT 2009 x86_64 GNU/Linux

Original issue reported on code.google.com by rel...@gmail.com on 19 Jun 2011 at 1:31

@GoogleCodeExporter
Copy link
Author

Looks like the parser expects every expression tree to be an array, but the 
code for parsing an "AGAINST" clause will return a single value rather than an 
array if the contents are a single value (on line 1112):

$processed = $list[0];

Changing this to return an array will fix the glitch for your particular code 
sample:

$processed = array($list[0]);

Regarding the print_r: It looks like the author put the print_r in there 
because that is an exceptional case that should normally never occur and 
signals a parsing bug.  But since you have the source code you can just comment 
it out :-)

It looks like there's another debug statement that occurs on lines 165-169 if 
the argument to parse is not a string:

if(!is_string($sql)) {
    echo "SQL:\n";
    print_r($sql);
    exit;
}

Original comment by kbacht...@gmail.com on 20 Oct 2011 at 5:16

@GoogleCodeExporter
Copy link
Author

I think, I have solved the parsing problem described by this issue.
Check out the bleeding edge on 
https://www.phosco.info/publicsvn/php-sql-parser/trunk/

Original comment by pho...@gmx.de on 17 Feb 2012 at 1:09

@GoogleCodeExporter
Copy link
Author

Accepted fixed codebase.

Original comment by greenlion@gmail.com on 12 Mar 2012 at 9:56

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant