spamspam252 / php-sql-parser Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/php-sql-parser
License: BSD 3-Clause "New" or "Revised" License
Automatically exported from code.google.com/p/php-sql-parser
License: BSD 3-Clause "New" or "Revised" License
The third test case within t/positions.php goes wrong, because of the regular
expression within lookForBaseExpression(). It awaits a delimiter between the
parts of the statement. The part u.uid=a.owner_id has no delimiter between
colref, operator and colref.
What version of the product are you using? On what operating system?
Version on http://www.phosco.info/php-sql-parser_current.zip
Original issue reported on code.google.com by [email protected]
on 7 Feb 2012 at 8:21
What steps will reproduce the problem?
INSERT INTO test (test2,test3) VALUES ('10','coucou')
What is the expected output?
...
["VALUES"]=>
array(2) {
[0]=>
string(4) "'10'"
[1]=>
string(8) "'coucou'"
}
...
What do you see instead?
...
["VALUES"]=>
array(1) {
[0]=>
string(15) "('10','coucou')"
}
...
What version of the product are you using? On what operating system?
trunk
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 1 Dec 2011 at 3:39
What steps will reproduce the problem?
1. Use a query that uses "cache" as the table name.
2. Other keywords can cause the same issue.
What is the expected output? What do you see instead?
The parse array uses "CACHE" keyword and does not parse the correct table part
of the query. Completely changes the parse tree.
What version of the product are you using? On what operating system?
PHP 5.3 on MAMP 2.0 install.
Is this something that can be fixed?
Original issue reported on code.google.com by [email protected]
on 2 Mar 2012 at 6:49
What steps will reproduce the problem?
1. execute the following code :
$sql = "SELECT 'a string with an escaped quote \' in it' AS some_alias FROM
some_table";
echo $sql . "\n";
$parser = new PHPSQLParser($sql, true);
print_r($parser->parsed);
What is the expected output? What do you see instead?
expected output : a SELECT and a FROM index in the parsed array.
instead : only a SELECT, and the base_expr is incorrect (contains the FROM
keyword and the end of the query)
Array
(
[SELECT] => Array
(
[0] => Array
(
[expr_type] => const
[alias] =>
[base_expr] => 'a string with an escaped quote \' in it' AS some_alias FROM some_table
[sub_tree] =>
[position] => 7
)
)
)
What version of the product are you using? On what operating system?
rev 235, on windows 7.
Original issue reported on code.google.com by [email protected]
on 20 Apr 2012 at 1:46
fixes issue 45.
Here is a test :
testsuite/tests/parser/issue45.php :
//////////////////////////////////////
<?php
require_once(dirname(__FILE__) . '/../../../php-sql-parser.php');
require_once(dirname(__FILE__) . '/../../test-more.php');
$parser = new PHPSQLParser();
$sql = "SELECT a from b left join c on c.a = b.a and (c.b. = b.b) where b.a >
1";
$parser->parse($sql, true);
$p = $parser->parsed;
$expected = getExpectedValue(dirname(__FILE__), 'issue45.serialized');
eq_array($p, $expected, 'does not die if subtree in join condition');
//////////////////////////////////////
and file with the serialized array :
testsuite/expected/parser/issue45.serialized :
a:3:{s:6:"SELECT";a:1:{i:0;a:5:{s:9:"expr_type";s:6:"colref";s:5:"alias";b:0;s:9
:"base_expr";s:1:"a";s:8:"sub_tree";b:0;s:8:"position";i:7;}}s:4:"FROM";a:2:{i:0
;a:9:{s:9:"expr_type";s:5:"table";s:5:"table";s:1:"b";s:5:"alias";b:0;s:9:"join_
type";s:4:"JOIN";s:8:"ref_type";b:0;s:10:"ref_clause";b:0;s:9:"base_expr";s:1:"b
";s:8:"sub_tree";b:0;s:8:"position";i:14;}i:1;a:9:{s:9:"expr_type";s:5:"table";s
:5:"table";s:1:"c";s:5:"alias";b:0;s:9:"join_type";s:4:"LEFT";s:8:"ref_type";s:2
:"ON";s:10:"ref_clause";a:5:{i:0;a:4:{s:9:"expr_type";s:6:"colref";s:9:"base_exp
r";s:3:"c.a";s:8:"sub_tree";b:0;s:8:"position";i:31;}i:1;a:4:{s:9:"expr_type";s:
8:"operator";s:9:"base_expr";s:1:"=";s:8:"sub_tree";b:0;s:8:"position";i:35;}i:2
;a:4:{s:9:"expr_type";s:6:"colref";s:9:"base_expr";s:3:"b.a";s:8:"sub_tree";b:0;
s:8:"position";i:37;}i:3;a:4:{s:9:"expr_type";s:8:"operator";s:9:"base_expr";s:3
:"and";s:8:"sub_tree";b:0;s:8:"position";i:41;}i:4;a:4:{s:9:"expr_type";s:10:"ex
pression";s:9:"base_expr";s:12:"(c.b. =
b.b)";s:8:"sub_tree";a:3:{i:0;a:4:{s:9:"expr_type";s:6:"colref";s:9:"base_expr";
s:4:"c.b.";s:8:"sub_tree";b:0;s:8:"position";i:46;}i:1;a:4:{s:9:"expr_type";s:8:
"operator";s:9:"base_expr";s:1:"=";s:8:"sub_tree";b:0;s:8:"position";i:51;}i:2;a
:4:{s:9:"expr_type";s:6:"colref";s:9:"base_expr";s:3:"b.b";s:8:"sub_tree";b:0;s:
8:"position";i:53;}}s:8:"position";i:45;}}s:9:"base_expr";s:31:"c on c.a = b.a
and (c.b. =
b.b)";s:8:"sub_tree";b:0;s:8:"position";i:26;}}s:5:"WHERE";a:3:{i:0;a:4:{s:9:"ex
pr_type";s:6:"colref";s:9:"base_expr";s:3:"b.a";s:8:"sub_tree";b:0;s:8:"position
";i:64;}i:1;a:4:{s:9:"expr_type";s:8:"operator";s:9:"base_expr";s:1:">";s:8:"sub
_tree";b:0;s:8:"position";i:68;}i:2;a:4:{s:9:"expr_type";s:5:"const";s:9:"base_e
xpr";s:1:"1";s:8:"sub_tree";b:0;s:8:"position";i:70;}}}
Original issue reported on code.google.com by [email protected]
on 23 Apr 2012 at 6:52
Attachments:
What steps will reproduce the problem?
1. execute following code :
$sql = 'SELECT a from b left join c on c.a = b.a and (c.b. = b.b) where a.a >
1';
$parser = new PHPSQLParser($sql, true);
2. script dies with the following message :
cannot calculate position of c on c.a = b.a and (c.b. = b.b) within ) where a.a
> 1
What is the expected output? What do you see instead?
Expected the query to be parsed correctly. Works if I change the query to :
$sql = 'SELECT a from b left join c on c.a = b.a and c.b. = b.b where a.a >
1';
or :
$sql = 'SELECT a from b left join c on (c.a = b.a and c.b. = b.b) where a.a >
1';
What version of the product are you using? On what operating system?
rev 235 on windows 7
Please provide any additional information below.
sorry if this is the same bug as issue 44
Original issue reported on code.google.com by [email protected]
on 22 Apr 2012 at 6:22
What steps will reproduce the problem?
1.
When parsing the following MySQL Query:
select usr_id, usr_login, case id_tipousuario when 1 then 'Usuario CVE' when 2
then concat('Usuario Vendedor -', codigovendedor, '-') when 3 then
concat('Usuario Vendedor Meson -', codigovendedor, '-') end tipousuario,
CONCAT( usr_nombres, ' ', usr_apellidos ) as nom_com, cod_local from usuarios
where usr_estado <> 2 order by 3, 1, 4
What is the expected output? What do you see instead?
and print_r the parsed thing you get:
SELECT =>
0 =>
expr_type => colref
alias => `usr_id`
base_expr => usr_id
sub_tree =>
1 =>
expr_type => colref
alias => `usr_login`
base_expr => usr_login
sub_tree =>
2 =>
expr_type => expression
alias => `tipousuario`
base_expr => case id_tipousuario when 1 then 'Usuario CVE' when 2 then concat('Usuario Vendedor -', codigovendedor, '-') when 3 then concat('Usuario Vendedor Meson -', codigovendedor, '-') end
sub_tree =>
0 =>
expr_type => operator
base_expr => case
sub_tree =>
1 =>
expr_type => colref
base_expr => id_tipousuario
sub_tree =>
2 =>
expr_type => operator
base_expr => when
sub_tree =>
3 =>
expr_type => const
base_expr => 1
sub_tree =>
4 =>
expr_type => reserved
base_expr => THEN
sub_tree =>
5 =>
expr_type => const
base_expr => 'Usuario CVE'
sub_tree =>
6 =>
expr_type => operator
base_expr => when
sub_tree =>
7 =>
expr_type => const
base_expr => 2
sub_tree =>
8 =>
expr_type => reserved
base_expr => THEN
sub_tree =>
9 =>
expr_type => function
base_expr => CONCAT
sub_tree =>
10 =>
expr_type => expression
base_expr => ('Usuario Vendedor -', codigovendedor, '-')
sub_tree =>
0 =>
expr_type => const
base_expr => 'Usuario Vendedor -'
sub_tree =>
1 =>
expr_type => colref
base_expr => ,
sub_tree =>
2 =>
expr_type => colref
base_expr => codigovendedor
sub_tree =>
3 =>
expr_type => colref
base_expr => ,
sub_tree =>
4 =>
expr_type => const
base_expr => '-'
sub_tree =>
11 =>
expr_type => operator
base_expr => when
sub_tree =>
12 =>
expr_type => const
base_expr => 3
sub_tree =>
13 =>
expr_type => reserved
base_expr => THEN
sub_tree =>
14 =>
expr_type => function
base_expr => CONCAT
sub_tree =>
15 =>
expr_type => expression
base_expr => ('Usuario Vendedor Meson -', codigovendedor, '-')
sub_tree =>
0 =>
expr_type => const
base_expr => 'Usuario Vendedor Meson -'
sub_tree =>
1 =>
expr_type => colref
base_expr => ,
sub_tree =>
2 =>
expr_type => colref
base_expr => codigovendedor
sub_tree =>
3 =>
expr_type => colref
base_expr => ,
sub_tree =>
4 =>
expr_type => const
base_expr => '-'
sub_tree =>
16 =>
expr_type => operator
base_expr => end
sub_tree =>
3 =>
expr_type => expression
alias => `nom_com`
base_expr => CONCAT( usr_nombres, ' ', usr_apellidos )
sub_tree =>
0 =>
expr_type => function
base_expr => CONCAT
sub_tree =>
1 =>
expr_type => expression
base_expr => ( usr_nombres, ' ', usr_apellidos )
sub_tree =>
0 =>
expr_type => colref
base_expr => usr_nombres
sub_tree =>
1 =>
expr_type => colref
base_expr => ,
sub_tree =>
2 =>
expr_type => const
base_expr => ' '
sub_tree =>
3 =>
expr_type => colref
base_expr => ,
sub_tree =>
4 =>
expr_type => colref
base_expr => usr_apellidos
sub_tree =>
4 =>
expr_type => colref
alias => `cod_local`
base_expr => cod_local
sub_tree =>
FROM =>
0 =>
table => usuarios
alias => usuarios
join_type => JOIN
ref_type =>
ref_clause =>
base_expr =>
sub_tree =>
WHERE =>
0 =>
expr_type => colref
base_expr => usr_estado
sub_tree =>
1 =>
expr_type => operator
base_expr => <>
sub_tree =>
2 =>
expr_type => const
base_expr => 2
sub_tree =>
ORDER =>
0 =>
type => pos
base_expr => 3
direction => ASC
1 =>
type => pos
base_expr => 1
direction => ASC
2 =>
type => pos
base_expr => 4
direction => ASC
That is correct however if you input the following MySQL query instead (
changes in red )
select usr_id, usr_login, case id_tipousuario when 1 then 'Usuario CVE' when 2
then concat('Usuario Vendedor -', codigovendedor, '-') when 3 then
concat('Usuario Vendedor Meson (', codigovendedor, ')') end tipousuario,
CONCAT( usr_nombres, ' ', usr_apellidos ) as nom_com, cod_local from usuarios
where usr_estado <> 2 order by 3, 1, 4
You get via print_r ( errors on red section at the bottom ) :
SELECT =>
0 =>
expr_type => colref
alias => `usr_id`
base_expr => usr_id
sub_tree =>
1 =>
expr_type => colref
alias => `usr_login`
base_expr => usr_login
sub_tree =>
2 =>
expr_type => expression
alias => `case id_tipousuario when 1 then 'Usuario CVE' when 2 then
concat('Usuario Vendedor -', codigovendedor, '-') when 3 then concat('Usuario
Vendedor Meson (', codigovendedor, ')')end tipousuario, CONCAT( usr_nombres, '
'`
base_expr => case id_tipousuario when 1 then 'Usuario CVE' when 2 then
concat('Usuario Vendedor -', codigovendedor, '-') when 3 then concat('Usuario
Vendedor Meson (', codigovendedor, ')')end tipousuario, CONCAT( usr_nombres, '
'
sub_tree =>
0 =>
expr_type => operator
base_expr => case
sub_tree =>
1 =>
expr_type => colref
base_expr => id_tipousuario
sub_tree =>
2 =>
expr_type => operator
base_expr => when
sub_tree =>
3 =>
expr_type => const
base_expr => 1
sub_tree =>
4 =>
expr_type => reserved
base_expr => THEN
sub_tree =>
5 =>
expr_type => const
base_expr => 'Usuario CVE'
sub_tree =>
6 =>
expr_type => operator
base_expr => when
sub_tree =>
7 =>
expr_type => const
base_expr => 2
sub_tree =>
8 =>
expr_type => reserved
base_expr => THEN
sub_tree =>
9 =>
expr_type => function
base_expr => CONCAT
sub_tree =>
10 =>
expr_type => expression
base_expr => ('Usuario Vendedor -', codigovendedor, '-')
sub_tree =>
0 =>
expr_type => const
base_expr => 'Usuario Vendedor -'
sub_tree =>
1 =>
expr_type => colref
base_expr => ,
sub_tree =>
2 =>
expr_type => colref
base_expr => codigovendedor
sub_tree =>
3 =>
expr_type => colref
base_expr => ,
sub_tree =>
4 =>
expr_type => const
base_expr => '-'
sub_tree =>
11 =>
expr_type => operator
base_expr => when
sub_tree =>
12 =>
expr_type => const
base_expr => 3
sub_tree =>
13 =>
expr_type => reserved
base_expr => THEN
sub_tree =>
14 =>
expr_type => function
base_expr => CONCAT
sub_tree =>
15 =>
expr_type => expression
base_expr => ('Usuario Vendedor Meson (', codigovendedor, ')')
sub_tree =>
0 =>
expr_type => const
base_expr => 'Usuario Vendedor Meson ('
sub_tree =>
1 =>
expr_type => colref
base_expr => ,
sub_tree =>
2 =>
expr_type => colref
base_expr => codigovendedor
sub_tree =>
3 =>
expr_type => colref
base_expr => ,
sub_tree =>
4 =>
expr_type => const
base_expr => ')'
sub_tree =>
16 =>
expr_type => colref
base_expr => end tipousuario, CONCAT( usr_nombres, '
sub_tree =>
17 =>
expr_type => const
base_expr => '
sub_tree =>
3 =>
expr_type => colref
alias => `nom_com`
base_expr => usr_apellidos
sub_tree =>
4 =>
expr_type => colref
alias => `cod_local`
base_expr => cod_local
sub_tree =>
FROM =>
0 =>
table => usuarios
alias => usuarios
join_type => JOIN
ref_type =>
ref_clause =>
base_expr =>
sub_tree =>
WHERE =>
0 =>
expr_type => colref
base_expr => usr_estado
sub_tree =>
1 =>
expr_type => operator
base_expr => <>
sub_tree =>
2 =>
expr_type => const
base_expr => 2
sub_tree =>
ORDER =>
0 =>
type => pos
base_expr => 3
direction => ASC
1 =>
type => pos
base_expr => 1
direction => ASC
2 =>
type => pos
base_expr => 4
direction => ASC
parse time simplest query:0.0099928379058838
RED IS :
expr_type => expression
base_expr => ('Usuario Vendedor Meson (', codigovendedor, ')')
sub_tree =>
0 =>
expr_type => const
base_expr => 'Usuario Vendedor Meson ('
sub_tree =>
1 =>
expr_type => colref
base_expr => ,
sub_tree =>
2 =>
expr_type => colref
base_expr => codigovendedor
sub_tree =>
3 =>
expr_type => colref
base_expr => ,
sub_tree =>
4 =>
expr_type => const
base_expr => ')'
sub_tree =>
16 =>
expr_type => colref
base_expr => end tipousuario, CONCAT( usr_nombres, '
sub_tree =>
17 =>
expr_type => const
base_expr => '
sub_tree =>
3 =>
expr_type => colref
alias => `nom_com`
base_expr => usr_apellidos
sub_tree =>
4 =>
expr_type => colref
alias => `cod_local`
base_expr => cod_local
sub_tree =>
What version of the product are you using? On what operating system?
svn trunk head revision windows and linux
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 23 Nov 2011 at 5:23
What steps will reproduce the problem?
1. subquery within the from clause
What is the expected output? What do you see instead?
Will not parse, instead throws error at line 965. It's missing '$this->' before
'removeParenthesisFromStart($token)'
What version of the product are you using? On what operating system?
Latest Version (issue 22) from http://www.phosco.info/php-sql-parser_current.zip
Original issue reported on code.google.com by [email protected]
on 7 Feb 2012 at 12:02
What steps will reproduce the problem?
1. Try to parse sql like "SELECT * FROM TableName".
What is the expected output? What do you see instead?
It should treat * as a reference to all columns without an alias. Instead, it
comes out as * is an "operator" with an alias of `*`.
What version of the product are you using? On what operating system?
Downloaded as of 10-20-2011.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 20 Oct 2011 at 4:53
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 [email protected]
on 19 Jun 2011 at 1:31
SELECT NOW();
or
SELECT test1
FROM table1
WHERE test_date < NOW();
I get a blank page showing this error :
Fatal error: Cannot use string offset as an array in
H:\Project\Openflyers30\classes\PHPSQLParser.php on line 1145
For any SQL queries where I've "NOW()", the parser always fails.
Original issue reported on code.google.com by [email protected]
on 5 Jan 2011 at 9:40
If I try to parse a complex query like this:
SELECT * FROM contacts WHERE contacts.id IN (SELECT email_addr_bean_rel.bean_id
FROM email_addr_bean_rel, email_addresses WHERE email_addresses.id =
email_addr_bean_rel.email_address_id AND email_addr_bean_rel.deleted = 0 AND
email_addr_bean_rel.bean_module = 'Contacts' AND email_addresses.email_address
IN ("[email protected]"))
then the query parser does not parse the internal subquery properly. The reason
for that is that trim functions which are used on encompassing subquery do
trim($sql, " ()") and thus when trimming they remove both enclosing parentheses
for the subquery and the ones that belong to inner IN, which they should not be
doing. I would propose to use something like this:
private function trimSubquery($sq)
{
$sq = trim($sq);
if(empty($sq)) return '';
while($sq[0] == '(' && substr($sq, -1) == ')') {
$sq = substr($sq, 1, -1);
$sq = trim($sq);
}
return $sq;
}
to keep trims balanced and use this functions instead of regular trim with '
()'.
Original issue reported on code.google.com by [email protected]
on 15 Feb 2012 at 1:13
I would like to see the parser support the CREATE TABLE statement.
Original issue reported on code.google.com by [email protected]
on 2 Mar 2012 at 6:45
What steps will reproduce the problem?
Parse the following query:
UPDATE user SET lastlogin = 7, x = 3;
What is the expected output? What do you see instead?
I expected the 'UPDATE' section to be present in the parsed member.
The 'UPDATE' section is wholly missing, only the 'SET' section exists.
Changing table name to 'users' works correctly, so it seems to be an issue with
the table name being a reserved word. The query runs fine on MySQL 5.x
What version of the product are you using? On what operating system?
Downloaded 2/29/2012. PHP 5.3.5 on 64-bit ubuntu Linux.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 1 Mar 2012 at 10:29
What steps will reproduce the problem?
1. Include a subquery in the column area of a 'Select' statement.
2. Be sure your subquery table name includes an escaped dollar symbol (e.g.,
v\$mytable)
3. You will get an error indicating the position of v\$mytable can't be found.
What is the expected output? What do you see instead?
I'm getting the error message in the subject indicating the position of the
table cannot be found
What version of the product are you using? On what operating system?
The latest to date.
Please provide any additional information below.
I'm also curious why the comparisons in the where clause don't classify column
comparisons (e.g., a.id=b.id) as JOINS instead of value/expression comparisons.
Original issue reported on code.google.com by [email protected]
on 10 Apr 2012 at 11:53
What steps will reproduce the problem?
1. parse a query like "SELECT * FROM test WHERE id>1"
What is the expected output? What do you see instead?
Expected output is:
[WHERE] => Array (
[0] => Array ( [expr_type] => colref [base_expr] => id [sub_tree] => )
[1] => Array ( [expr_type] => operator [base_expr] => > [sub_tree] => )
[2] => Array ( [expr_type] => const [base_expr] => 1 [sub_tree] => )
)
Instead we get:
[WHERE] => Array (
[0] => Array ( [expr_type] => colref [base_expr] => id [sub_tree] => )
[1] => Array ( [expr_type] => colref [base_expr] => >1 [sub_tree] => )
)
What version of the product are you using? On what operating system?
I tested this with revision 36 on linux. Works ok with "WHERE id > 1"
Original issue reported on code.google.com by [email protected]
on 4 Apr 2011 at 12:52
use DIRECTORY_SEPARATOR constant so test suite can be run on an OS that does
not use slashes as directory separators.
Original issue reported on code.google.com by [email protected]
on 23 Apr 2012 at 4:28
Attachments:
What steps will reproduce the problem?
Parse the following query:
SELECT sp.level,
CASE sp.level
WHEN 'bronze' THEN 0
WHEN 'silver' THEN 1
WHEN 'gold' THEN 2
ELSE -1
END AS levelnum,
sp.alt_en,
sp.alt_pl,
DATE_FORMAT(sp.vu_start,'%Y-%m-%d %T') AS vu_start,
DATE_FORMAT(sp.vu_stop,'%Y-%m-%d %T') AS vu_stop,
ABS(TO_DAYS(now()) - TO_DAYS(sp.vu_start)) AS frdays,
ABS(TO_DAYS(now()) - TO_DAYS(sp.vu_stop)) AS todays,
IF(ISNULL(TO_DAYS(sp.vu_start)) OR ISNULL(TO_DAYS(sp.vu_stop))
, 1
, IF(TO_DAYS(now()) < TO_DAYS(sp.vu_start)
, TO_DAYS(now()) - TO_DAYS(sp.vu_start)
, IF(TO_DAYS(now()) > TO_DAYS(sp.vu_stop)
, TO_DAYS(now()) - TO_DAYS(sp.vu_stop)
, 0))) AS status,
st.id,
SUM(IF(st.type='view',1,0)) AS view,
SUM(IF(st.type='click',1,0)) AS click
FROM stats AS st,
sponsor AS sp
WHERE st.id=sp.id
GROUP BY st.id
ORDER BY sp.alt_en asc, sp.alt_pl asc
What is the expected output? What do you see instead?
Query should parse... (it runs on MySQL 5.x)
I get this:
Notice: Uninitialized string offset: 0 in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 677 Notice:
Undefined variable: processed in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 1241 Notice:
Undefined variable: processed in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 1243 Notice:
Undefined variable: expr_type in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 1247 Warning:
array_pop() expects parameter 1 to be array, string given in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 717 Notice:
Uninitialized string offset: 0 in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 744 Notice:
Undefined variable: processed in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 1241 Notice:
Undefined variable: processed in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 1243 Notice:
Undefined variable: expr_type in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 1247 Notice:
Uninitialized string offset: 0 in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 762 Fatal error:
Cannot use string offset as an array in
/media/sf_swjozef2/vendor/sqlparser/php-sql-parser.php on line 762
What version of the product are you using? On what operating system?
Downloaded on 2/29/2012, running on ubuntu Linux 64-bit, PHP 5.3.5
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 1 Mar 2012 at 10:04
What steps will reproduce the problem?
<?php
require("php-sql-parser.php");
require("php-sql-creator.php");
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
$sql = "INSERT INTO test (`name`, `test`) VALUES ('Hello this is what happens\n
when new lines are involved', '')";
$parser = new PHPSQLParser($sql);
$ben = new PHPSQLCreator($parser->parsed);
echo "<textarea>";
echo $sql;
echo "</textarea>";
echo "<textarea>";
print_r( $parser->parsed );
echo "</textarea>";
echo "<textarea>";
echo $ben->created;
echo "</textarea>";
What is the expected output? What do you see instead?
Expected output
---------------
INSERT INTO test (`name`, `test`) VALUES ('Hello this is what happens
when new lines are involved', '')
Observed output
---------------
INSERT INTO test (`name`,`test`) VALUES ('Hello this is what happens when new
lines are involved','')
What version of the product are you using? On what operating system?
https://www.phosco.info/publicsvn/php-sql-parser/trunk/ REV 136
Please provide any additional information below.
It appears that it's dropped in the parser class rather than the creator class.
Original issue reported on code.google.com by [email protected]
on 12 Mar 2012 at 11:29
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 17 Feb 2012 at 4:25
The parser doesn't recognize functions within INSERT statements. You will get
the function name as column reference and the function parameters as expression.
Used version:
https://www.phosco.info/publicsvn/php-sql-parser/tags/20120215
Original issue reported on code.google.com by [email protected]
on 16 Feb 2012 at 9:08
If you have a subquery which has an alias, the alias is part of the
"base_expr". It is complicated to parse it (there can be additional aliases
within the subquery or the alias is very short like "s", which can be part of
the subquery string too). So it would be nice to remove the alias from the
"base_expr" like in the "table" part.
Original issue reported on code.google.com by [email protected]
on 23 Jan 2012 at 2:49
What steps will reproduce the problem?
1. use the query ;)
What is the expected output? What do you see instead?
SELECT *
FROM (t1 LEFT JOIN t2 ON t1.a=t2.a)
LEFT JOIN t3
ON t2.b=t3.b OR t2.b IS NULL
(taken from
http://dev.mysql.com/doc/refman/5.0/en/nested-join-optimization.html)
is parsed to
[SELECT] => Array
(
[0] => Array
(
[expr_type] => operator
[alias] => `*`
[base_expr] => *
[sub_tree] =>
)
)
[FROM] => Array
(
[0] => Array
(
[table] => (t1 LEFT JOIN t2 ON t1.a=t2.a)
[alias] => (t1 LEFT JOIN t2 ON t1.a=t2.a)
[join_type] => JOIN
[ref_type] =>
[ref_clause] =>
[base_expr] =>
[sub_tree] =>
)
[1] => Array
(
[table] => t3
[alias] => t3
[join_type] => LEFT
[ref_type] => ON
[ref_clause] => t2.b=t3.b OR t2.b IS NULL
[base_expr] =>
[sub_tree] =>
)
)
i expect the (t1... part to be parsed into two tables
What version of the product are you using? On what operating system?
latest on zend server using php 5.3
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 29 Apr 2011 at 9:22
1. Provide WHERE clause with string constants with inner parentheses:
"RIGHT(REPLACE(foo.bar,'(0',''),7) = 'a'"
2. Parsing result is incorrect
Expected:
Array
(
[SELECT] => Array
(
[0] => Array
(
[expr_type] => colref
[alias] => `dummy`
[base_expr] => dummy
[sub_tree] =>
)
)
[FROM] => Array
(
[0] => Array
(
[table] => dummytable
[alias] => dummytable
[join_type] => JOIN
[ref_type] =>
[ref_clause] =>
[base_expr] =>
[sub_tree] =>
)
)
[WHERE] => Array
(
[0] => Array
(
[expr_type] => function
[base_expr] => RIGHT
[sub_tree] =>
)
[1] => Array
(
[expr_type] => expression
[base_expr] => (REPLACE(foo.bar,'(0',''),7)
[sub_tree] => Array
(
[0] => Array
(
[expr_type] => function
[base_expr] => REPLACE
[sub_tree] =>
)
[1] => Array
(
[expr_type] => expression
[base_expr] => (foo.bar,'(0','')
[sub_tree] => Array
(
[0] => Array
(
[expr_type] => colref
[base_expr] => foo.bar
[sub_tree] =>
)
[1] => Array
(
[expr_type] => colref
[base_expr] => ,
[sub_tree] =>
)
[2] => Array
(
[expr_type] => const
[base_expr] => '(0'
[sub_tree] =>
)
[3] => Array
(
[expr_type] => colref
[base_expr] => ,
[sub_tree] =>
)
[4] => Array
(
[expr_type] => const
[base_expr] => ''
[sub_tree] =>
)
)
)
[2] => Array
(
[expr_type] => colref
[base_expr] => ,
[sub_tree] =>
)
[3] => Array
(
[expr_type] => const
[base_expr] => 7
[sub_tree] =>
)
)
)
[2] => Array
(
[expr_type] => operator
[base_expr] => =
[sub_tree] =>
)
[3] => Array
(
[expr_type] => const
[base_expr] => 'a'
[sub_tree] =>
)
)
)
Actual:
Array
(
[SELECT] => Array
(
[0] => Array
(
[expr_type] => colref
[alias] => `dummy`
[base_expr] => dummy
[sub_tree] =>
)
)
[FROM] => Array
(
[0] => Array
(
[table] => dummytable
[alias] => dummytable
[join_type] => JOIN
[ref_type] =>
[ref_clause] =>
[base_expr] =>
[sub_tree] =>
)
)
[WHERE] => Array
(
[0] => Array
(
[expr_type] => function
[base_expr] => RIGHT
[sub_tree] =>
)
[1] => Array
(
[expr_type] => colref
[base_expr] => (REPLACE(foo.bar,'(0',''),7) = 'a'
[sub_tree] =>
)
)
)
Fix for this issue: change count_paren method:
from
private function count_paren($token,$chars=array('(',')')) {
$len = strlen($token);
$open=array();
$close=array();
for($i=0;$i<$len;++$i){
if($token[$i] == $chars[0]) {
$open[] = $i;
} elseif($token[$i] == $chars[1]) {
$close[] = $i;
}
}
return array('open' => $open, 'close' => $close, 'balanced' =>( count($close) - count($open)));
}
to
private function count_paren($token,$chars=array('(',')')) {
$len = strlen($token);
$open=array();
$close=array();
$quotes = '';
for($i=0;$i<$len;++$i){
if (in_array($token[$i], array('"', "'"))) {
if ($quotes == $token[$i]) {
$quotes = '';
} elseif (!strlen($quotes)) {
$quotes = $token[$i];
}
} elseif (!strlen($quotes)) {
if($token[$i] == $chars[0]) {
$open[] = $i;
} elseif($token[$i] == $chars[1]) {
$close[] = $i;
}
}
}
return array('open' => $open, 'close' => $close, 'balanced' =>( count($close) - count($open)));
}
Original issue reported on code.google.com by [email protected]
on 29 Feb 2012 at 9:58
What steps will reproduce the problem?
1. execute this code :
$parser = new PHPSQLParser();
$sql = "SELECT _utf8'hi'";
$parser->parse($sql, true);
2. script dies with this message :
cannot calculate position of _utf8 within _utf8'hi'
What is the expected output? What do you see instead?
Expected the parser to return an array with one element in the SELECT array.
What version of the product are you using? On what operating system?
rev 235 on windows 7.
Please provide any additional information below.
failing test case :
-----------
<?php
require_once(dirname(__FILE__) . '/../../../php-sql-parser.php');
require_once(dirname(__FILE__) . '/../../test-more.php');
$parser = new PHPSQLParser();
$sql = "SELECT _utf8'hi'";
$parser->parse($sql, true);
$p = $parser->parsed;
$expected = getExpectedValue(dirname(__FILE__), 'issue50.serialized');
eq_array($p, $expected, 'does not die if query contains _utf8 construct');
Original issue reported on code.google.com by [email protected]
on 24 Apr 2012 at 9:31
What steps will reproduce the problem?
1. Try an parse the following query:
2. UPDATE table1 SET field1='foo' WHERE field2='bar' AND id=(SELECT if FROM
test1 t where t.field1=(SELECT id from test2 t2 where t2.field = 'foo'))
Granted, its my own typo ("if" should be "id" in the first subselect) but I
dont think php-sql-parser should be throwing an undefined offset exception.
What is the expected output? What do you see instead?
Expected: Blank screen.
See instead: Notice: Undefined offset: 1 in /var/www/php-sql-parser.php on line
1102
Can be fixed by changing line 1102 of php-sql-parser.php from:
$sub_expr = $tokens[$key+1];
to:
if(!empty($tokens[$key+1])) $sub_expr = $tokens[$key+1];
Original issue reported on code.google.com by [email protected]
on 2 Jan 2011 at 2:50
What steps will reproduce the problem?
Parse the following query:
SELECT title, introtext
FROM kj9un_content
WHERE `id`='159'
What is the expected output? What do you see instead?
$parsed['FROM'][0]['table'] = 'kj9un_content'
I get
$parsed['FROM'][0]['table'] = 'kj9un_content
WHERE'
Original issue reported on code.google.com by [email protected]
on 20 Apr 2012 at 5:05
There is a problem with explicit ASC statements within ORDER-BY. It is not
filtered from the base_expr. So the creator class generates it twice.
Version:
https://www.phosco.info/publicsvn/php-sql-parser/tags/20120217
Original issue reported on code.google.com by [email protected]
on 20 Feb 2012 at 8:18
Test code :
$test = str_repeat('0', 18000);
$query = "UPDATE club SET logo='$test' WHERE id=1";
$parser = new PHPSQLParser();
$result = $parser->parse($query);
Result : query cannot be parsed and cause the current PHP process to
crash/timeout.
Original issue reported on code.google.com by [email protected]
on 20 May 2011 at 5:33
What steps will reproduce the problem?
1. The following two queries won't be exploded consistently:
$q1 = "select a from t where x = \"a'b\\cd\" and y = 'ef\"gh'";
$q2 = "select a from t where x = \"abcd\" and y = 'efgh'";
$parser = new CPHPSQLParser();
print_r($parser->parse($q1));
print_r($parser->parse($q2));
What is the expected output? What do you see instead?
$q1 and $q2 should have in the [WHERE] part two colref/operator/const parts,
with only different constant/colref values. Instead, the [WHERE] for q1 has
only one colref/operator/const part, like this: colref = "x", operator = "=" ,
const "a'b\cd" and y = 'ef"gh'
What version of the product are you using? On what operating system?
tags/2012-03-23 / win7
Please provide any additional information below.
The parser doesn't correctly handle values with escaped chars inside (no matter
if the value is single or double quoted inside the query).
Original issue reported on code.google.com by [email protected]
on 30 Mar 2012 at 1:55
SELECT * FROM SURVEYS inner join SURVEYS_LANGUAGESETTINGS on
(surveyls_survey_id=sid and surveyls_language=language) WHERE sid=74191
returns in the FROM clause:
[FROM] => Array
(
[0] => Array
(
[table] => SURVEYS
[alias] => SURVEYS
[join_type] => JOIN
[ref_type] =>
[ref_clause] =>
[base_expr] =>
[sub_tree] =>
)
[1] => Array
(
[table] => SURVEYS_LANGUAGESETTINGS
[alias] => SURVEYS_LANGUAGESETTINGS
[join_type] => JOIN
[ref_type] => ON
[ref_clause] => surveyls_survey_id=sid and surveyls_language=language
[base_expr] =>
[sub_tree] =>
)
)
Can you parse the ref_clause, that I will have colrefs?
Thanks a lot
Andre
Original issue reported on code.google.com by [email protected]
on 20 Jan 2012 at 1:00
Hi,
I try to use your parser within a small project. I need the table names and
their aliases within a SELECT statement to check, which columns are used within
the ORDER BY clause. The first test produces a problem:
SELECT * FROM answers ORDER BY qid
The parser generates an alias ANSWERS, but the table doesn't have an alias. So
it is not possible to find column names within the ORDER clause with the alias
(the alias can or cannot be a valid alias).
Please remove the alias from the resulting array, if the table doesn't have an
alias within the SQL statement.
Thanks a lot
Andre
Original issue reported on code.google.com by [email protected]
on 20 Jan 2012 at 8:12
After some modification on the array.
Original issue reported on code.google.com by [email protected]
on 26 Aug 2011 at 4:31
What steps will reproduce the problem?
1. Parse - Create : SELECT COUNT(DISTINCT BLA) FROM FOO
What is the expected output? What do you see instead?
expect
SELECT COUNT(DISTINCT BLA) FROM FOO
get
unknow expression type bla bla in processSELECT because of missing processing func
also the innards are beeing ,-concatinated which is not expected for such a
DISTINCT
What version of the product are you using? On what operating system?
lastest svn
Please provide any additional information below.
a better error handling (instead of prints) would also be welcome
Original issue reported on code.google.com by [email protected]
on 20 Mar 2012 at 12:12
Here an example query :
SELECT SUM( 10 ) FROM account
There is a tab character before the SUM function. I've a class which use
php-sql-parser to perform internal extra validation.
The example query causes my parser to fail.
But with this query where I've replaced tab character by a space :
SELECT SUM( 10 ) FROM account
My parser doesn't fail.
Parser result with tab character :
[SELECT] => Array
(
[0] => Array
(
[expr_type] => expression
[alias] => `SUM( 10 as test`
[base_expr] => SUM( 10 as test
[sub_tree] => Array
(
[0] => Array
(
[expr_type] => aggregate_function
[base_expr] => SUM
[sub_tree] =>
)
[1] => Array
(
[expr_type] => colref
[base_expr] => ( 10 as test
[sub_tree] =>
)
)
)
)
Parser result with space character :
[SELECT] => Array
(
[0] => Array
(
[expr_type] => expression
[alias] => `test`
[base_expr] => SUM( 10 )
[sub_tree] => Array
(
[0] => Array
(
[expr_type] => aggregate_function
[base_expr] => SUM
[sub_tree] =>
)
[1] => Array
(
[expr_type] => const
[base_expr] => ( 10 )
[sub_tree] =>
)
)
)
)
Should this bug be fixed onto php-sql-parser or my own class ?
The fix would be to do a : str_replace("\t", ' ', $query);
Original issue reported on code.google.com by [email protected]
on 23 Jan 2012 at 11:07
What steps will reproduce the problem?
1. parse the query
What is the expected output? What do you see instead?
query:
SELECT a.field1, b.field1, c.field1
FROM tablea a
LEFT OUTER JOIN tableb b ON b.ida = a.id
LEFT OUTER JOIN tablec c ON c.idb = b.id
result:
[SELECT] => Array
(
[0] => Array
(
[expr_type] => colref
[alias] => `a.field1`
[base_expr] => a.field1
[sub_tree] =>
)
[1] => Array
(
[expr_type] => colref
[alias] => `b.field1`
[base_expr] => b.field1
[sub_tree] =>
)
[2] => Array
(
[expr_type] => colref
[alias] => `c.field1`
[base_expr] => c.field1
[sub_tree] =>
)
)
[FROM] => Array
(
[0] => Array
(
[table] => tablea
[alias] => a
[join_type] => JOIN
[ref_type] =>
[ref_clause] =>
[base_expr] =>
[sub_tree] =>
)
[1] => Array
(
[table] => tableb
[alias] => b
[join_type] => LEFT LEFT JOIN
[ref_type] => ON
[ref_clause] => OUTER
[base_expr] =>
[sub_tree] =>
)
[2] => Array
(
[table] => tablec
[alias] => c
[join_type] => JOIN
[ref_type] => ON
[ref_clause] => c.idb = b.id
[base_expr] =>
[sub_tree] =>
)
)
i am missing the reference b.ida = a.id (and the last join should be left outer)
What version of the product are you using? On what operating system?
latest (29.04.2011) on zend server php 5.3
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 29 Apr 2011 at 9:19
What steps will reproduce the problem?
1. execute testsuite/tests-parser.php (on windows)
2. get warning failed to open stream: Invalid argument on file_get_contents call
What is the expected output? What do you see instead?
expected passing suite. See instead warnings and failed tests.
What version of the product are you using? On what operating system?
rev 235 on windows 7
Please provide any additional information below.
it works if this line :
$path = explode("/", $path);
is replaced by :
$path = explode(DIRECTORY_SEPARATOR, $path);
in the getExpectedValue() function in test-more.php
Original issue reported on code.google.com by [email protected]
on 23 Apr 2012 at 4:24
What steps will reproduce the problem?
<?php
require("php-sql-parser.php");
require("php-sql-creator.php");
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
$sql = "SELECT * FROM `table` `t` WHERE ( ( UNIX_TIMESTAMP() + 3600 ) >
`t`.`expires` ) ";
$parser = new PHPSQLParser($sql);
echo "<pre>";
print_r( new PHPSQLCreator($parser->parsed) );
What is the expected output? What do you see instead?
Expected output
---------------
"SELECT * FROM `table` `t` WHERE ( ( UNIX_TIMESTAMP() + 3600 ) > `t`.`expires`
) ";
Observed output
---------------
unknown expr_type in WHERE expression subtree[0] expression
What version of the product are you using? On what operating system?
https://www.phosco.info/publicsvn/php-sql-parser/trunk/ REV 141
Please provide any additional information below.
I believe this is in php-sql-creator.php as opposed to php-sql-parser.php
Original issue reported on code.google.com by [email protected]
on 13 Mar 2012 at 10:03
Is it possible to return the positions of the statement components within the
original SQL string? I have to replace some column names, but I don't know,
where the column name is used within the statement. A simple string replace
doesn't work in all cases.
Thanks
Andre
Original issue reported on code.google.com by [email protected]
on 20 Jan 2012 at 8:23
What steps will reproduce the problem?
<?php
// require("php-sql-parser.php");
require("PHPSQLParser.php");
$sql = "INSERT INTO test (`name`) VALUES ('ben\'s test containing an escaped
quote')";
$parser = new PHPSQLParser($sql);
echo "<pre>";
print_r( $parser->parsed );
echo "</pre>";
What is the expected output? What do you see instead?
EXPECTED:
[VALUES] => Array
(
[0] => ('ben\'s test containing an escaped quote')
)
OBSERVED:
[VALUES] => Array
(
[0] => ('ben''s test containing an escaped quote')
)
What version of the product are you using? On what operating system?
Both of the following have the issue:
http://www.phosco.info/php-sql-parser_current.zip
http://php-sql-parser.googlecode.com/svn/trunk/php-sql-parser.php
Original issue reported on code.google.com by [email protected]
on 5 Mar 2012 at 10:32
Well, this query is well parsed :
$parser = new PHPSQLParser();
$query = "INSERT INTO test (test2,test3) VALUES ('10','coucou')";
$result = $parser->parse($query);
But for this one :
$parser = new PHPSQLParser();
$query = "INSERT INTO test (test2,test3) VALUES('10','coucou')";
$result = $parser->parse($query);
There is no data "RESULT" into the array. The part "('10','coucou')" is not
parsed so I cannot know which values were affected to columns of table test.
That's just because there is not a space between "VALUES" and "(".
Original issue reported on code.google.com by [email protected]
on 9 May 2011 at 1:57
SELECT q.qid, question, gid FROM questions as q WHERE (select count(*) from
answers as a where a.qid=q.qid and scale_id=0)=0 and sid=11929 AND type IN
('F', 'H', 'W', 'Z', '1') and q.parent_qid=0
goes wrong, the in-list contains commas, so we will get from the creator:
SELECT q.qid,question,gid FROM questions q WHERE (SELECT count(*) FROM answers
a WHERE a.qid = q.qid and scale_id = 0) = 0 and sid = 11929 AND type IN ('F',,
,'H',, ,'W',, ,'Z',, ,'1') and q.parent_qid = 0
Version:
https://www.phosco.info/publicsvn/php-sql-parser/tags/20120217
Original issue reported on code.google.com by [email protected]
on 22 Feb 2012 at 3:13
What steps will reproduce the problem?
select * from test where value<>"brainstorm"
Suggestion
i removed the "|([^ ,]+)" from the preg_split(),
fixed this problem for me, but don't know if it is breaking somthing.
What is the expected output?
[WHERE] => Array
(
[0] => Array
(
[expr_type] => colref
[base_expr] => value
[sub_tree] =>
)
[1] => Array
(
[expr_type] => operator
[base_expr] => <>
[sub_tree] =>
)
[2] => Array
(
[expr_type] => const
[base_expr] => "brainstorm"
[sub_tree] =>
)
)
What do you see instead?
[WHERE] => Array
(
[0] => Array
(
[expr_type] => colref
[base_expr] => value
[sub_tree] =>
)
[1] => Array
(
[expr_type] => colref
[base_expr] => <>"brainstorm"
[sub_tree] =>
)
)
Original issue reported on code.google.com by [email protected]
on 2 Mar 2011 at 1:20
What steps will reproduce the problem?
Try to parse this query with position option set to true
SELECT m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params,
mm.menuid
FROM kj9un_modules AS m
LEFT JOIN kj9un_modules_menu AS mm ON mm.moduleid = m.id
LEFT JOIN kj9un_extensions AS e ON e.element = m.module AND e.client_id =
m.client_id
WHERE m.published = 1 AND e.enabled = 1 AND (m.publish_up = '0000-00-00
00:00:00' OR m.publish_up <= '2012-04-21 09:44:01') AND (m.publish_down =
'0000-00-00 00:00:00' OR m.publish_down >= '2012-04-21 09:44:01') AND m.access
IN (1,1) AND m.client_id = 0 AND (mm.menuid = 170 OR mm.menuid <= 0) AND
m.language IN ('en-GB','*')
ORDER BY m.position, m.ordering
cannot calculate position of 1 within AND m.client_id = 0 AND (mm.menuid = 170 OR mm.menuid <= 0) AND m.language IN ('en-GB','*') ORDER BY m.position, m.ordering
Ends in: cannot calculate position of 1 within AND m.client_id = 0 AND
(mm.menuid = 170 OR mm.menuid <= 0) AND m.language IN ('en-GB','*') ORDER BY
m.position, m.ordering
What version of the product are you using? On what operating system?
Todays version
Original issue reported on code.google.com by [email protected]
on 21 Apr 2012 at 9:54
If I try :
$parser = new PHPSQLParser('SELECT
name, 1, test;');
PHP is giving me error (see method process_select_expr):
- Warning: E_WARNING array_pop() expects parameter 1 to be array, string given
- Fatal error: Cannot use string offset as an array
A newline after between SELECT and field list makes the parser to fail.
Original issue reported on code.google.com by [email protected]
on 14 Dec 2010 at 4:06
if(count($processed) == 1) {
...
}
produces errors on some sql-statments.
i added:
if(is_array($processed)) {
if(count($processed) == 1) {
...
}
}
Original issue reported on code.google.com by [email protected]
on 2 Mar 2011 at 1:28
What steps will reproduce the problem?
1. Execute SELECT pl_namespace,pl_title FROM `pagelinks` WHERE pl_from = '1'
FOR UPDATE
What is the expected output? What do you see instead?
I saw:
[WHERE] => Array
(
[0] => Array
(
[expr_type] => colref
[base_expr] => pl_from
[sub_tree] =>
)
[1] => Array
(
[expr_type] => operator
[base_expr] => =
[sub_tree] =>
)
[2] => Array
(
[expr_type] => const
[base_expr] => '1'
[sub_tree] =>
)
[3] => Array
(
[expr_type] => reserved
[base_expr] => UPDATE
[sub_tree] =>
)
)
But i was expecting:
[WHERE] => Array
(
[0] => Array
(
[expr_type] => colref
[base_expr] => pl_from
[sub_tree] =>
)
[1] => Array
(
[expr_type] => operator
[base_expr] => =
[sub_tree] =>
)
[2] => Array
(
[expr_type] => const
[base_expr] => '1'
[sub_tree] =>
)
)
What version of the product are you using? On what operating system?
I am running Ubuntu 11.10. And using the version in the site in the Dec 7 2010
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 7 Dec 2011 at 1:51
What steps will reproduce the problem?
1. execute this code :
$sql = 'SELECT [CONCAT(a, b)] from c';
$parser = new PHPSQLParser($sql, true);
2. script dies with this message :
cannot calculate position of b) within , b)] from c
What is the expected output? What do you see instead?
The documentation says the query should be well-formed, so this is probably
more of an enhancement request. Would it be possible to throw an Exception
instead of using 'die' and 'exit' in the library?
Or is there an easy way for the client code to recover from such an error?
What version of the product are you using? On what operating system?
r235 on windows7
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 22 Apr 2012 at 6:30
What steps will reproduce the problem?
require("php-sql-parser.php");
require("php-sql-creator.php");
$sql = "INSERT INTO test (`name`, `test`) VALUES ('\'Superman\'', ''),
('\'Superman\'', '')";
$parser = new PHPSQLParser($sql);
$ben = new PHPSQLCreator($parser->parsed);
print_r( $sql );
What is the expected output? What do you see instead?
Expected output
---------------
INSERT INTO test (`name`, `test`) VALUES ('\'Superman\'', ''), ('\'Superman\'',
'')
Observed output
---------------
unknown expr_type in VALUES[2] expression
Also (This may be related)
Observed output
---------------
[VALUES] => Array
(
[0] => Array
(
[expr_type] => const
[base_expr] => '\'Superman\''
[sub_tree] =>
)
[1] => Array
(
[expr_type] => const
[base_expr] => ''
[sub_tree] =>
)
[2] => Array
(
[expr_type] => expression
[base_expr] => ('\'Superman\'', '')
[sub_tree] => Array
(
[0] => Array
(
[expr_type] => const
[base_expr] => '\'Superman\''
[sub_tree] =>
)
[1] => Array
(
[expr_type] => colref
[base_expr] => ,
[sub_tree] =>
)
[2] => Array
(
[expr_type] => const
[base_expr] => ''
[sub_tree] =>
)
)
)
)
Note the [1] array key in the expression sub tree. This presumably is incorrect.
What version of the product are you using? On what operating system?
https://www.phosco.info/publicsvn/php-sql-parser/trunk/ REV 136
Original issue reported on code.google.com by [email protected]
on 12 Mar 2012 at 10:07
What steps will reproduce the problem?
1. use the parser to parse a query like Select table.`field` from table
2.
3.
What is the expected output? What do you see instead?
if you look at the 'Select' statement generated you will get
Array
(
[0] => Array
(
[expr_type] => colref
[alias] => `prj_seq_key`
[base_expr] => aje.
[sub_tree] =>
)
)
where you sould get
Array
(
[0] => Array
(
[expr_type] => colref
[alias] => aje.`prj_seq_key`
[base_expr] => aje.prj_seq_key`
[sub_tree] =>
)
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 13 Jan 2011 at 12:40
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.