I need to turn PostgreSQL query strings in my application, such as:
$db_query_string = '
SELECT *
FROM "the schema"."a table" -- This is an SQL comment. At least in PostgreSQL.
WHERE blabla = 123
AND "another column" = $1
ORDER BY
whatever DESC
';
into a "token symbol structure", just like with token_get_all() for PHP code, so that I get something like an array of "symbols" along the lines of (this is just an example and not an exact requirement):
[
'SELECT_TOKEN',
'ASTERISK_TOKEN',
'FROM_TOKEN',
'SCHEMA_TOKEN' => 'the schema',
'TABLE_TOKEN' => 'a table',
'COMMENT_TOKEN' => 'This is an SQL comment. At least in PostgreSQL.',
'WHERE_TOKEN',
'BLABLABLA'...
]
Etc. You get the point.
I find nothing when searching online. The closest I've seen is something for MySQL, but I didn't even visit that search result as I have no use for something that only works with MySQL. It has to work with PostgreSQL's flavour of SQL.