I want to parse a SQL query into an array. I could not figure out the code.
Example:
$sql_query = "SELECT id, login, pass FROM users WHERE id=3, login=faforty ORDER DESC LIMIT 3"';
and this sql query should be as follows:
$data = array();
$data['select'] = array('id', 'login', 'pass');
$data['from'] = array('id' => 3, 'login' => 'faforty');
$data['order'] = 'desc';
$data['limit'] = 3;
Query may be different.
Use an SQL parser. http://code.google.com/p/php-sql-parser/
Copy paste from this example:
Example output: