diff options
author | Michal Čihař <michal@cihar.com> | 2016-03-07 16:20:03 +0100 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2016-03-07 16:20:03 +0100 |
commit | ba604eff3e2e6ca8bf9d6005e65cdad4d82345f9 (patch) | |
tree | 9f3ef1023b3312b28d80e73fec37f0323409a54b | |
parent | ad0e75faa6f6943d013f23d0d1ca31b4781e7b79 (diff) | |
download | sql-parser-ba604eff3e2e6ca8bf9d6005e65cdad4d82345f9.zip sql-parser-ba604eff3e2e6ca8bf9d6005e65cdad4d82345f9.tar.gz sql-parser-ba604eff3e2e6ca8bf9d6005e65cdad4d82345f9.tar.bz2 |
Add at least some basic examples to README
Issue #42
Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r-- | README.md | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -9,6 +9,37 @@ A validating SQL lexer and parser with a focus on MySQL dialect. [](https://codecov.io/github/phpmyadmin/sql-parser?branch=master) [](https://scrutinizer-ci.com/g/phpmyadmin/sql-parser/?branch=master) +## Installation + +Please use [Composer][1] to install: + +``` +composer require phpmyadmin/sql-parser +``` + +## Usage + +### Formatting SQL query + +```php +echo SqlParser\Utils\Formatter::format($query, array('type' => 'html'); +``` + +### Parsing and building SQL query + +```php +$parsed = new SqlParser\Parser($query); + +// you can now inspect or change query +var_dump($parser->statements[0]); + +// and build it again +$statement = $parser->statements[0]; +$statement->build() +``` + ## More information This library was originally during the Google Summer of Code 2015 and has been used by phpMyAdmin since version 4.5. + +[1]:https://getcomposer.org/ |