PHP: Check validity of SQL before process it to Mysql
Is there any class or library to ph开发者_开发百科p, for this task?
Thanks ;)
You could set up a local mySQL database with mock tables to have statement executed there first. This will take less resources than the real request and you can then check for errors. You could write a thin wrapper for that.
If you want to check if query executes without errors you can call it within transaction and rollback in the end.
You can prepare the sql statement first using prepare() function. If it return false, then there are errors. Otherwise, you are good to go.
Good luck.
精彩评论