PHPackages                             manticoresoftware/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. manticoresoftware/php-sql-parser

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

manticoresoftware/php-sql-parser
================================

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

v4.6.0-patch15(11mo ago)259.2k↓16.7%1BSD-3-ClausePHPPHP &gt;=5.3.2CI passing

Since Feb 24Pushed 11mo agoCompare

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

READMEChangelog (10)Dependencies (3)Versions (20)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c09c6169a21f411b2f8fbebfaa83b5f4f8300bf25b6df3c6da9bed8a3e468498/68747470733a2f2f7472617669732d63692e6f72672f677265656e6c696f6e2f5048502d53514c2d5061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/greenlion/PHP-SQL-Parser)

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

39

—

LowBetter than 86% of packages

Maintenance50

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.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 ~32 days

Total

15

Last Release

358d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/28718748?v=4)[Manticore Search](/maintainers/manticoresearch)[@manticoresearch](https://github.com/manticoresearch)

---

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 (123 commits)")[![polevaultweb](https://avatars.githubusercontent.com/u/1770201?v=4)](https://github.com/polevaultweb "polevaultweb (20 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)")[![KlimTodrik](https://avatars.githubusercontent.com/u/19153169?v=4)](https://github.com/KlimTodrik "KlimTodrik (11 commits)")[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (7 commits)")[![gilbitron](https://avatars.githubusercontent.com/u/203882?v=4)](https://github.com/gilbitron "gilbitron (7 commits)")[![nicoder](https://avatars.githubusercontent.com/u/365210?v=4)](https://github.com/nicoder "nicoder (6 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)")[![czoIg](https://avatars.githubusercontent.com/u/11523297?v=4)](https://github.com/czoIg "czoIg (4 commits)")[![jdorrestijn](https://avatars.githubusercontent.com/u/36915981?v=4)](https://github.com/jdorrestijn "jdorrestijn (4 commits)")[![Herz3h](https://avatars.githubusercontent.com/u/1900696?v=4)](https://github.com/Herz3h "Herz3h (3 commits)")[![xsist10](https://avatars.githubusercontent.com/u/415488?v=4)](https://github.com/xsist10 "xsist10 (3 commits)")[![nabab](https://avatars.githubusercontent.com/u/193892?v=4)](https://github.com/nabab "nabab (3 commits)")[![gluneaumt](https://avatars.githubusercontent.com/u/12433326?v=4)](https://github.com/gluneaumt "gluneaumt (2 commits)")[![shokre](https://avatars.githubusercontent.com/u/6144138?v=4)](https://github.com/shokre "shokre (2 commits)")[![sebastien-fauvel](https://avatars.githubusercontent.com/u/4215521?v=4)](https://github.com/sebastien-fauvel "sebastien-fauvel (2 commits)")

---

Tags

parsermysqlsqlcreator

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/manticoresoftware-php-sql-parser/health.svg)](https://phpackages.com/packages/manticoresoftware-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.

47950.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)
