View Full Version : Code highlight & format SQL queries (looking for feedback)

01-06-2006, 11:51 AM

Iíve written a script that is basically a much enhanced version of var_dump, any way, thatís not what this posts about.

I have just added a new feature to the script which can code highlight (in various colours) and format SQL Queries (the query string not the result). I wrote it because I often have dynamically generated queries that donít work and I need to inspect, and this script makes it much easier to look through the query to find mistakes.

I am looking for people to test it out, give me some feedback and generally let me know what they think. Any feedback will be greatly appreciated. Please note that the script only supports the SQL clauses and operators that I used while testing, I know the clause lists arenít complete, its something I will be adding, however that doesnít stop you seeing how it all works. If anyone wants to help out completing the lists, feel free :-) .

Script: Here (http://www.reallyshiny.com/scripts/php-dump/)

Here are two example queries (although not valid SQL, they demonstrate the functionality), and an image of the output from my script:

SELECT id, title, content, datePosted, status, MAX(comments) AS maxComments FROM blog WHERE status = 1 AND comments > 5 ORDER BY datePosted DESC LIMIT 0, 5

INSERT INTO blog (title, content, status) VALUES ('Test Article', 'Test test test test test', 1)


Cheers! :)

01-06-2006, 12:17 PM
You can't DL it from that site.
Wow I found it
BTW: http://qbnz.com/highlighter/

01-06-2006, 12:35 PM
That other script is good, but it only highlights the code, it dosent format it with line breaks and tabs etc, but thanks for the link.

Anyway, the purpose of that program and the purpose of my scripts are different. Their program is just for hilighting code, to print out or display on a web page I guess. My script is part of a larger class called PHP Dump, which is for quickly debugging things like arrays and queries, and it displays them in an easy to read way. Basically an enhanced version of var_dump.

The idea of my SQL formatting is if you have a query with an error, you can quicky parse the query string through the dump function and inspect it.