"convert Google-like strings into standard SQL queries"

"convert Google-like strings into standard SQL queries"

by Dan Stowell -
Number of replies: 3
As requested on the "Some nice little projects" page, I had a go at a function for converting "Google-like" strings into SQL queries.

The following webpage has my function for writing the WHERE clause. The specification talks about sorting etc, which I haven't got round to, but hopefully this is a useful start:

http://www.ucl.ac.uk/is/fiso/lifesciences/test/gtosql/

I've not tested the SQL on a database yet; it's very simple SQL so far though.
Average of ratings: -
In reply to Dan Stowell

Re: "convert Google-like strings into standard SQL queries"

by Gunther Dippe -
Looks like a great start smile
Cheers
In reply to Dan Stowell

Re: "convert Google-like strings into standard SQL queries"

by Tony Hursh -
I saw the same problem and started tinkering with it without realizing you'd already started, sorry.

I found a nice public domain PHP lexer class on Sourceforge and thought it looked like a lazy man's way of solving the problem (although it's probably overkill). After seeing that you'd started on the problem, I thought about stopping but then decided to push on just to improve my PHP skills.

The code is attached, and there's a demo at:

http://teachanything.net/test/testsearch.php

Right now I'm not planning on developing it any further (you beat me to it, fair and square smile), but I thought others might find the code useful (maybe for other applications in Moodle, even).

It's really quite nifty to see Bison/Yacc/lex/flex-like functionality in PHP. The more I use PHP the more I like it. smile

I expect your hand-coded parser has better performance. OTOH, the lexer method may be easier to extend.

Nice job!



Average of ratings: Useful (1)