jdorn / sql-formatter

A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.
http://jdorn.github.com/sql-formatter/
MIT License
3.89k stars 186 forks source link

PHP Notice: Undefined offset: -1 #57

Closed bueltge closed 10 years ago

bueltge commented 10 years ago

I have the follow notice on the class. Maybe you have ad hoc a idea. Current was not easy to debug, how you start the $i and which values. I think is a problem, if the value $i is 0.

Notice: Undefined offset: -1 in C:\xampp\htdocs\wp-plugins\debug-objects\inc\SqlFormatter\SqlFormatter.php on line 679

Thanks for the project.

jdorn commented 10 years ago

Can you send me the query that caused the error? You can take out any sensitive information if you need to. On Jan 12, 2014 5:20 AM, "Frank Bültge" notifications@github.com wrote:

I have the follow notice on the class. Maybe you have ad hoc a idea. Current was not easy to debug, how you start the $i and which values. I think is a problem, if the value $i is 0.

Notice: Undefined offset: -1 in C:\xampp\htdocs\wp-plugins\debug-objects\inc\SqlFormatter\SqlFormatter.php on line 679

Thanks for the project.

— Reply to this email directly or view it on GitHubhttps://github.com/jdorn/sql-formatter/issues/57 .

jdorn commented 10 years ago

Nevermind, I'm able to reproduce it by using any query that starts with "."

bueltge commented 10 years ago

@jdorn nice, the commit fix my problem. It was not possible for to send you the query at hoc. I have a loop with 73 queries and it was not easy to find the init query, that create the notice. I use your class inside a debug helper for WordPress - https://github.com/bueltge/Debug-Objects. best regards