I have database in mysql. On the php application I want to create a textarea and allow users to write a "query" to filter the data on the table.
I want to create a query parser for users to filter data by writing a query. For example:
name="John" AND (age > 20 OR status = 1)
Something like this. This is what users will type and press search button and the system creates sql query out of the "query" provided by user and return filtered results. In the example above, it will create sql query like this:
SELECT * FROM users WHERE name="John" AND (age>20 OR status=1)
I am thinking of parsing this query with regex and create sql from it. Is there any better approach?