FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19356&edit=1

ID: 19356
Updated by: daniel.oconnor@gmail.com
Reported By: bpolaszek at gmail dot com
Summary: Unable to parse any query
-Status: Open
+Status: Bogus
Type: Bug
Package: SQL_Parser
Operating System: Linux
Package Version: 0.6.0
PHP Version: 5.2.17
Roadmap Versions:
New Comment:

-Status: Open
+Status: Bogus
Take a look at
http://svn.php.net/viewvc/pear/packages/SQL_Parser/trunk/tests/test_update.phpt?
revision=316127&view=markup


Previous Comments:
------------------------------------------------------------------------

[2012-03-28 23:47:57] bengates

Description:
------------
Hello,

I'm sorry to post this into the bugtracker but neither the
official documentation nor Google could help
me.
I was looking for a class or a function that could parse an SQL
query with its special words, knowing the
tables it wants to use, the WHERE clauses, etc, into an array.

I found your class that should exactly do the work I need, as I
found on a blog :
http://www.sjhannah.com/blog/?p=16

That's exactly what I'm looking for.

So, I downloaded the SQL Parser Package, the Pear Package
(I'm not very familiar with it), put
everything into my include directory, opened and empty php
file and wrote the folowing :

[Look in test script]

This is a very simple query, but I can take any query, I only
have the following result :

[Look the actual result]

What have I done wrong ?
Thank you in advance,
Ben

Test script:
---------------
# Constant definitions for PHP Files
define('MAIN_PATH', getcwd());
define('INC_PATH', MAIN_PATH . '/inc');

# Main inclusions
set_include_path(get_include_path() . ":" . INC_PATH . '/Pear');
require_once('PEAR.php');
require_once('SQLParser/Parser.php');

$parser = new SQL_Parser(null, 'MySQL');
$struct = $parser->parse("SELECT foo FROM bar");
print_r($struct);


Expected result:
----------------
The parsed SQL query into an array

Actual result:
--------------
Caught exception: Parse error: Unknown action: S on line 1
SELECT foo FROM bar ^ found: "S" in: /homez.99/ [...]
/inc/Pear/SQLParser/Parser.php#318 from:
#0 /homez.99/ [...] /inc/Pear/SQLParser/Parser.php(1751):
SQL_Parser->raiseError('Unknown action:...')
#1 /homez.99/ [...] /inc/Pear/SQLParser/Parser.php(1792):
SQL_Parser->parseQuery()
#2 /homez.99/ [...] /index.php(26): SQL_Parser-
parse('SELECT foo FROM...') #3 {main}
------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedApr 1, '12 at 12:51p
activeApr 1, '12 at 12:51p
posts1
users1
websitepear.php.net

1 user in discussion

Daniel Oconnor: 1 post

People

Translate

site design / logo © 2022 Grokbase