PHPackages                             zent/php-sql-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. zent/php-sql-parser

ActiveLibrary[Database &amp; ORM](/categories/database)

zent/php-sql-parser
===================

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

v4.1.3(7y ago)1237BSD-3-ClausePHPPHP &gt;=5.3.2

Since Apr 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/zen1t/PHP-SQL-Parser)[ Packagist](https://packagist.org/packages/zent/php-sql-parser)[ Docs](https://github.com/greenlion/PHP-SQL-Parser)[ RSS](/packages/zent-php-sql-parser/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

PHP-SQL-Parser
==============

[](#php-sql-parser)

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

### Download

[](#download)

[GitHub Wiki](https://github.com/greenlion/PHP-SQL-Parser/wiki/Downloads)

### Full support for the MySQL dialect for the following statement types

[](#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-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](https://github.com/greenlion/PHP-SQL-Parser/wiki/Parser-Manual) for more information.

### Other SQL dialects

[](#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](https://github.com/greenlion/PHP-SQL-Parser/wiki/Parser-Manual). It supports UNION, subqueries and compound statements.

### External dependencies

[](#external-dependencies)

The parser is a self contained class. It has no external dependencies. The parser uses a small amount of regex.

### Focus

[](#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.

### Manual

[](#manual)

[ParserManual](https://github.com/greenlion/PHP-SQL-Parser/wiki/Parser-Manual) - Check out the manual.

### Example Output

[](#example-output)

**Example Query**

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

**Example Output (via print\_r)**

```
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] =>
                )

        )

)
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 93.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~400 days

Total

5

Last Release

2813d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2409b3dfa6e57995690cde523af82d5b952ee77b9ebd8372fd351acbd4ad26ae?d=identicon)[zen1t](/maintainers/zen1t)

---

Top Contributors

[![witchi](https://avatars.githubusercontent.com/u/5766508?v=4)](https://github.com/witchi "witchi (2331 commits)")[![greenlion](https://avatars.githubusercontent.com/u/465334?v=4)](https://github.com/greenlion "greenlion (95 commits)")[![donatj](https://avatars.githubusercontent.com/u/133747?v=4)](https://github.com/donatj "donatj (19 commits)")[![dbould](https://avatars.githubusercontent.com/u/5477476?v=4)](https://github.com/dbould "dbould (12 commits)")[![polevaultweb](https://avatars.githubusercontent.com/u/1770201?v=4)](https://github.com/polevaultweb "polevaultweb (12 commits)")[![zen1t](https://avatars.githubusercontent.com/u/9872888?v=4)](https://github.com/zen1t "zen1t (7 commits)")[![yfix](https://avatars.githubusercontent.com/u/659419?v=4)](https://github.com/yfix "yfix (6 commits)")[![PSF1](https://avatars.githubusercontent.com/u/10193279?v=4)](https://github.com/PSF1 "PSF1 (5 commits)")[![oohook](https://avatars.githubusercontent.com/u/4328913?v=4)](https://github.com/oohook "oohook (4 commits)")[![gluneaumt](https://avatars.githubusercontent.com/u/12433326?v=4)](https://github.com/gluneaumt "gluneaumt (2 commits)")[![oscar3x39](https://avatars.githubusercontent.com/u/3096182?v=4)](https://github.com/oscar3x39 "oscar3x39 (1 commits)")[![greggunner](https://avatars.githubusercontent.com/u/909758?v=4)](https://github.com/greggunner "greggunner (1 commits)")[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (1 commits)")[![sk-sparhandy](https://avatars.githubusercontent.com/u/7532845?v=4)](https://github.com/sk-sparhandy "sk-sparhandy (1 commits)")[![xRahul](https://avatars.githubusercontent.com/u/1639945?v=4)](https://github.com/xRahul "xRahul (1 commits)")

---

Tags

parsermysqlsqlcreator

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/zent-php-sql-parser/health.svg)

```
[![Health](https://phpackages.com/badges/zent-php-sql-parser/health.svg)](https://phpackages.com/packages/zent-php-sql-parser)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[greenlion/php-sql-parser

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

63911.6M82](/packages/greenlion-php-sql-parser)[catfan/medoo

The lightweight PHP database framework to accelerate development

4.9k1.5M194](/packages/catfan-medoo)[phpmyadmin/sql-parser

A validating SQL lexer and parser with a focus on MySQL dialect.

47750.4M55](/packages/phpmyadmin-sql-parser)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
