Refactoring SQL executor

transferring code related to parsing the sql query to the sql parser from sql.php