Query regexp
Archived from the Xataface Developers forum.
Jean — Mon Jul 06, 2009 11:58 pm
Hi Steve,
I tried with your new SQL lib from the SVN
My query is
- Code: Select all
select * from annuaire_enligne WHERE nom NOT REGEXP '([0-9]{4})' ORDER BY nom
It may come from the line 1465 in the Parser.php in lib/SQL/.
But even without the parenthesis, the error still is displayed.
- Code: Select all
while ($this->token == 'ident' or $this->token == '(') { if ( $this->token == 'ident' ){ $tableType = 'ident'; $this->all_tables[] = $tree['table_names'][] = $tableName = $this->tokText; } else { //must be a subselect. $this->getTok(); if ( $this->token != 'select' ){ return $this->raiseError('Expected "select" on line '.__LINE__.' of file '.__FILE__); }
And the error is
Warning: Cannot use a scalar value as an array in /var/www/html/xataface-1.1.5r2/lib/SQL/Parser.php on line 1693
Warning: Cannot use a scalar value as an array in /var/www/html/xataface-1.1.5r2/Dataface/Table.php on line 1971
Warning: Invalid argument supplied for foreach() in /var/www/html/xataface-1.1.5r2/Dataface/Table.php on line 1971
I tried
- Code: Select all
__sql__="select * from annuaire_enligne WHERE CAST(nom as SIGNED INT)NOT BETWEEN 2000 AND 8000 ORDER BY nom"
but the result is the same.
Although an error is displayed, it seems that the query is still working.
I hope it helps.
Thank you
Jean
shannah — Tue Jul 07, 2009 6:22 am
Are you sure it’s using the SVN version? When I go to line 1693 of SQL/Parser.php it has:
- Code: Select all
if ( PEAR::isError($ret) ){
Which could not be causing the error listed as it isn’t referencing anything as an array.
Jean — Tue Jul 07, 2009 7:20 am
Steve,
I don’t understand, I’ve checked up, I downloaded the file from
http://weblite.ca/svn/dataface/core/trunk/lib/SQL/
and replace it into /var/www/html/xataface-1.1.5r2/lib/SQL/
Jean
shannah — Tue Jul 07, 2009 10:28 am
Sorry. Seems I had forgotten to check in the latest version. If you download SQL/Parser.php from svn now, it will be the latest version. However, this version will still fail - … but it will give a more descriptive error showing what it doesn’t like about the SQL query.
Jean — Tue Jul 07, 2009 10:37 am
Fine, thank you again, Steve, I’ll tell you.
Jean
Jean — Tue Jul 07, 2009 11:49 pm
Yes, Steve, the message is a bit more explicit
Fatal error: Failed parsing SQL query on select: Fatal error: Failed parsing SQL query on select: select * from annuaire_enligne WHERE nom NOT REGEXP ‘[0-9]{4}’ ORDER BY nom in /var/www/html/xataface-1.1.5r2/lib/SQL/Parser.php on line 1694
for one and the other
Fatal error: Failed parsing SQL query on select: select * from annuaire_enligne WHERE CAST(nom as SIGNED INT) NOT BETWEEN 2000 AND 8000 ORDER BY nom in /var/www/html/xataface-1.1.5r2/lib/SQL/Parser.php on line 1694
I managed to use an other request that works.
Jean
shannah — Thu Jul 09, 2009 6:59 am
I have fixed the SQL parser to handle this case. (See issue http://bugs.weblite.ca/view.php?id=517).
Try out the latest from SVN at http://weblite.ca/svn/dataface/core/trunk/lib/SQL
-Steve
Jean — Thu Jul 09, 2009 11:51 pm
Thank you Steve, yes it works now.
For your information, the second one didn’t.
kind regards
Jean