Yellow Bird Yellow Bird - 1 year ago 108
MySQL Question

How can I check a MySQL query syntax?

I'm working on my own database management system, developped in PHP, and I've chosen the same syntax as the MySQL queries for my own queries.

I'd like to know if there was a tool to check that a MySQL query is valid, without having to connect to a real MySQL database.

Does someone have a way to do it ? I've though about using some regular expressions but I'm not sure this is the easiest (and fastest) way to do this.

Thank in advance !

Answer Source

There's a few good PHP SQL parsers that break down the query into structured arrays.

You could run the code through the parser and see if it breaks to determine whether it's valid syntax.


are 2 I have used in the past.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download