On the browser side, the user will be entering a boolean query, which could grow complex, which I want to translate into an SQL SELECT
statement.
The user will enter a text string, along the lines of a AND ((b OR c) OR (not d))
. As I said, this is an arbitrary text string, containing a boolean expression.
It's for a software recruiter, so a, b, c, d, etc will be skills, like C, C++, UML, Python, etc, so that the previous example might actually read C++ AND ((UML OR Python) OR (not Perl))
.
Which I want to expand to (in this case) SELECT * FROM candidates WHERE skill=C++ AND ((skill=UML OR skill=Python) OR (not skill=Perl))
.
I can prepend the SELECT
statement, but how do I translate (e.g) C++ AND ((UML OR Python) OR (not Perl))
to skill=C++ AND ((skill=UML OR skill=Python) OR (not skill=Perl))
and do it for any arbitrary boolean expression, with any number of brackets, in PHP?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…