What is a good method for parsing an sql string into it separate components. I’v tried with a regex, however I can’t get it to work just right.
Say for instance:
'SELECT * FROM tbl WHERE user_id > 50'
Would create an array with all the components
$arr[0] = 'SELECT'; $arr[1] = '*'; $arr[2] = 'FROM';
ect…
Thank you
I’d go for a sql parser that could be integrated to your language: don’t reinvent the wheel.
I haven’t used one in particular to recommend, but I’m sure that you can find one that do what you need.
See related: PHP MySQL SQL parser (INSERT and UPDATE)