Page 1 of 1

Color a mysql query?

Posted: Mon Aug 02, 2004 9:54 pm
by phice
Are there any query colorers out there? I can't seem to find any using Google, yet I've seen mysql queries colored before.

Any help?

Posted: Mon Aug 02, 2004 11:19 pm
by kettle_drum
Umm. Theres a web-based one here: http://tripleasp.net/Services/ShowCode.asmx but your probably best just coding your own.

Posted: Tue Aug 03, 2004 8:33 am
by JAM
You could also look at the phpMyAdmin solution as I did:

Just one interesting place: /libraries/sqlparser.lib.php(1996): function PMA_SQP_buildCssData()

Posted: Tue Aug 03, 2004 3:58 pm
by phice
JAM is on the right track, but it's too built into the system to really take anything away from it.

Posted: Tue Aug 03, 2004 4:23 pm
by JAM
What!? Wasn't that a good challenge for you? ;)
I'll see what I have in the store, though i doubt saving this...

Another idea is to look at taglists/wordlists that alot of win32 software use to internally syntax highlight code (among others, SQL). Is there a get_defined_functions() for mysql? Never thought of it, but if so, youre halfways there...

Edit II:
Download the mysql source, and check out the /sql/lex.h file (functions) and /Docs/reservedwords.texi (reserved words) for a good start...

Edited:
I couldn't find the old work, so I whipped something easy together to get you started. Took some data from phpMyAdmin to help me get started...
> Demo and source example

For others reading: Yes, it's ugly. Yes, it can be done better, but... It more fun to do something by yourself isn't it? ;)