Interpreting SQL with PHP
php, sql
Solution
I've used the php-sql-parser project which is open source and pretty good.
Problem
So, I need to use PHP to pull out field names and values from the where statement of a sql query, change them, then put the thing back together. So, say I'm given this string: `field='value' AND field2<7` I need to recognize field and field2 as field names, then feed then through the function `field()` and put them back into the query. Same things with 'value' and 7, but feed them through a `value()` function. It would also help to know what field each value was associated with. Is there any way to do this that won't take a few thousand lines to code? I need it to work with a lot of different possible inputs, including things like: `table.field BETWEEN 7 AND 10` or `field<7 AND (field2=3 OR field3=4)`