greenlion/php-sql-parser
Composer 安装命令:
composer require greenlion/php-sql-parser
包简介
A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL
README 文档
README
PHP-SQL-Parser
A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL
Download
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.
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.
External dependencies
The parser is a self contained class. It has no external dependencies. The parser uses a small amount of regex.
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
ParserManual - Check out the manual.
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] => ) ) )
greenlion/php-sql-parser 适用场景与选型建议
greenlion/php-sql-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.23M 次下载、GitHub Stars 达 640, 最近一次更新时间为 2014 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sql」 「parser」 「mysql」 「creator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 greenlion/php-sql-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 greenlion/php-sql-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 greenlion/php-sql-parser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Query filtering in your frontend
An MT940 bank statement parser for PHP
Database/ORM-agnostic query construction helper
Laravel integration for the jsonapi.org parser
统计信息
- 总下载量: 12.23M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 653
- 点击次数: 21
- 依赖项目数: 92
- 推荐数: 2
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-01-13