changing query syntax

Post Reply
basement_addict
Posts: 78
Joined: Mon Nov 19, 2001 5:20 pm

changing query syntax

Post by basement_addict »

Hi,

We have a client that would like to change the way they query to something like what monster does:

http://help.monster.com/js20/index.asp? ... t#location


examples:

php AND mysql AND apache

(php OR vortex) AND (oracle OR sqlite) AND linux


I was thinking I'd have to build a string parser to map the syntax to a texis query but I thought of checking with you guys first so I don't reinvent the wheel.

Thanks
User avatar
jason112
Site Admin
Posts: 347
Joined: Tue Oct 26, 2004 5:35 pm

changing query syntax

Post by jason112 »

Actually, this is something we've just integrated in Webinator, these are the relevant bits:

<sandr "\space+>>OR=\space+" "," $sqlq>
<sandr "\space+>>AND=\space+NOT=\space+" ") -(" $ret>
<sandr "\space+>>NOT=\space+" ") -(" $ret>
<sandr "\space+>>AND=\space+" ") (" $ret>
<sandr ">>=\space+" "" $ret>
<sandr "\space+>>=" "" $ret>
<strfmt "(%s)" $ret>
<sandr ">>(=[^,)]+)=" '"\2"' $ret>

This supports AND, OR, NOT, and AND NOT. Note that it doesn't take parenthesis, but it will do what your second example wants with

php OR vortex AND oracle OR sqlite AND linux

Edit: fixed some repetition operators to properly match multiple spaces.
Post Reply