This is more for analyzing a query in PHP BEFORE it\'s sent to the server. Very complicated why im doing this, so i\'d rather not go into the reason for this.
In PHP
For anyone coming across this question in the future someone has already gone to the trouble of writting an SQL parser in PHP.
At present it supports SELECT, INSERT, UPDATE, DELETE and REPLACE statements.