5 Command line tool to validate (syntax check) SQL files.
6 Primarily for MySQL ``.sql`` files.
8 Can be used in git pre-commit hooks to catch errors.
9 Use it from your shell, offline and without any SQL server.
11 You can also use it to format SQL queries.
19 $ php-sqllint tests/files/create-missingcomma.sql
20 Checking SQL syntax of tests/files/create-missingcomma.sql
21 Line 3, col 5 at "pid": A comma or a closing bracket was expected.
22 Line 3, col 13 at "11": Unexpected beginning of statement.
23 Line 3, col 17 at "DEFAULT": Unrecognized statement type.
27 $ php-sqllint -r emacs tests/files/create-noname.sql
28 tests/files/create-noname.sql:1.12:Error: The name of the entity was expected.
29 tests/files/create-noname.sql:1.13:Error: A closing bracket was expected.
30 tests/files/create-noname.sql:1.13:Error: At least one column definition was expected.
35 $ php-sqllint --format tests/files/select-unformatted.sql
43 DATE > NOW() AND id != 0
50 ANSI colors are applied automatically when not piping; you can use the
51 ``--highlight`` option to override the automatism.
53 ``--highlight`` option values:
56 No highlighting. Use it to disable automatic highlighting
58 ANSI escape codes for your shell
66 Does ``php-sqllint`` not detect a syntax error, or doesn't support a certain
68 Then please report a bug at `phpmyadmin/sql-parser`__.
70 __ https://github.com/phpmyadmin/sql-parser
76 The download files are equipped with all dependencies.
77 Just download and run.
79 Version 0.1.1, 2016-04-14
81 - `php-sqllint-0.1.1.bz2.phar <http://cweiske.de/download/php-sqllint/php-sqllint-0.1.1.bz2.phar>`__
84 - SHA256: ``c1902d79636e112715682260c21980ac51059688b7fb1a8eda4a8ca70226e56b``
85 - `php-sqllint-0.1.1.phar <http://cweiske.de/download/php-sqllint/php-sqllint-0.1.1.phar>`__
88 - SHA256: ``2665a0c1cf8997c326a90ebded5a7848a1d60506d98158b391a8e546afa2ca20``
94 - PEAR's `Console_Commandline`__
95 - `phpMyAdmin's SqlParser`__, which is used by `phpMyAdmin`__
97 __ http://pear.php.net/package/Console_CommandLine
98 __ https://github.com/phpmyadmin/sql-parser
99 __ https://www.phpmyadmin.net/
102 Dependency installation
103 =======================
108 Now you can use ``./bin/php-sqllint`` without building the phar yourself.
117 1. Write new version number into ``VERSION``
122 You'll need `phing`__, the PHP build tool::
126 __ https://www.phing.info/
128 The result are ``.phar`` files in ``dist/`` directory that you can execute::
130 $ ./dist/php-sqllint-0.0.1.phar tests/files/create-noname.sql
131 Checking SQL syntax of tests/files/create-noname.sql
132 Line 1, col 12 at "(": The name of the entity was expected.
141 ``php-sqllint`` is licensed under the `AGPL v3`__ or later.
143 __ http://www.gnu.org/licenses/agpl.html
149 http://cweiske.de/php-sqllint.htm
151 http://git.cweiske.de/php-sqllint.git
153 Mirror: https://github.com/cweiske/php-sqllint
160 __ http://cweiske.de/