2017 © Pedro PelĂĄez
 

library php-sql-parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

image

greenlion/php-sql-parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  • Friday, November 17, 2017
  • by witchi
  • Repository
  • 18 Watchers
  • 291 Stars
  • 353,396 Installations
  • PHP
  • 32 Dependents
  • 1 Suggesters
  • 70 Forks
  • 76 Open issues
  • 7 Versions
  • 10 % Grown

The README.md

Build Status, (*1)

PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL, (*2)

Download

GitHub Wiki
, (*3)

Full support for the MySQL dialect for the following statement types

SELECT
INSERT
UPDATE
DELETE
REPLACE
RENAME
SHOW
SET
DROP
CREATE INDEX
CREATE TABLE
EXPLAIN
DESCRIBE

Other SQL statement types

Other statements are returned as an array of tokens. This is not as structured as the information available about the above types. See the ParserManual for more information., (*4)

Other SQL dialects

Since the MySQL SQL dialect is very close to SQL-92, this should work for most database applications that need a SQL parser. If using another database dialect, then you may want to change the reserved words - see the ParserManual. It supports UNION, subqueries and compound statements., (*5)

External dependencies

The parser is a self contained class. It has no external dependencies. The parser uses a small amount of regex., (*6)

Focus

The focus of the parser is complete and accurate support for the MySQL SQL dialect. The focus is not on optimizing for performance. It is expected that you will present syntactically valid queries., (*7)

Manual

ParserManual - Check out the manual., (*8)

Example Output

Example Query, (*9)

SELECT STRAIGHT_JOIN a, b, c 
  FROM some_table an_alias
 WHERE d > 5;

Example Output (via print_r), (*10)

Array
( 
    [OPTIONS] => Array
        (
            [0] => STRAIGHT_JOIN
        )       

    [SELECT] => Array
        (
            [0] => Array
                (
                    [expr_type] => colref
                    [base_expr] => a
                    [sub_tree] => 
                    [alias] => `a`
                )

            [1] => Array
                (
                    [expr_type] => colref
                    [base_expr] => b
                    [sub_tree] => 
                    [alias] => `b`
                )

            [2] => Array
                (
                    [expr_type] => colref
                    [base_expr] => c
                    [sub_tree] => 
                    [alias] => `c`
                )

        )

    [FROM] => Array
        (
            [0] => Array
                (
                    [table] => some_table
                    [alias] => an_alias
                    [join_type] => JOIN
                    [ref_type] => 
                    [ref_clause] => 
                    [base_expr] => 
                    [sub_tree] => 
                )

        )

    [WHERE] => Array
        (
            [0] => Array
                (
                    [expr_type] => colref
                    [base_expr] => d
                    [sub_tree] => 
                )

            [1] => Array
                (
                    [expr_type] => operator
                    [base_expr] => >
                    [sub_tree] => 
                )

            [2] => Array
                (
                    [expr_type] => const
                    [base_expr] => 5
                    [sub_tree] => 
                )

        )

)

The Versions

17/11 2017

dev-master

9999999-dev https://github.com/greenlion/PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

sql parser mysql creator

16/05 2017

v4.1.2

4.1.2.0 https://github.com/greenlion/PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

sql parser mysql creator

05/11 2016

dev-development

dev-development https://github.com/greenlion/PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

sql parser mysql creator

12/10 2016

v4.1.1

4.1.1.0 https://github.com/greenlion/PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

sql parser mysql creator

08/07 2016

v4.1.0

4.1.0.0 https://github.com/greenlion/PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

sql parser mysql creator

16/04 2014

v4.0.0

4.0.0.0 http://code.google.com/p/php-sql-parser/

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.2

 

The Development Requires

sql parser mysql creator

12/04 2014

dev-customfuncs

dev-customfuncs http://code.google.com/p/php-sql-parser/

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

  Sources   Download

BSD New

The Requires

  • php >=5.2.13

 

The Development Requires

sql parser mysql creator