koriym/dev-pdo-statement
Composer 安装命令:
composer require koriym/dev-pdo-statement
包简介
A PDOStatement for develop
关键字:
README 文档
README
[Japanese]
koriym/dev-pdo-statement log following information to help your sql inspection.
- Query excution time.
- Final SQL query with parameter values interpolated into it from prepared statement.
- The result of
EXPLAINquery. - The result of
SHOW WARNINGSquery.
Install
AttachDevPdoStatementclass to the target $pdo.
use Koriym\DevPdoStatement\DevPdoStatement; use Koriym\DevPdoStatement\Logger; $pdo->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [DevPdoStatement::class, [$pdo, new Logger]]);
Then $pdo start to log as following on each query.
time:0.00035190582275391 query: INSERT INTO user(id, name) VALUES (99, 'koriym99')
time:0.00020503997802734 query: SELECT id, name FROM user where id > 80
warnings:[
{
"Level": "Note",
"Code": "1003",
"Message": "\/* select#1 *\/ select `tmp`.`user`.`id` AS `id`,`tmp`.`user`.`name` AS `name` from `tmp`.`user` where (`tmp`.`user`.`id` > 80)"
}
]
explain :[
{
"id": "1",
"select_type": "SIMPLE",
"table": "user",
"partitions": null,
"type": "ALL",
"possible_keys": null,
"key": null,
"key_len": null,
"ref": null,
"rows": "100",
"filtered": "33.33",
"Extra": "Using where"
}
]
Custom Log
You can implement custom condition for logging or choose your favorite logger.
use Koriym\DevPdoStatement\LoggerInterface; class MyPsr3Logger implements LoggerInterface { /** * {@inheritdoc} */ public function logQuery($query, $time, array $explain, array $warnings) { // log or throw exception in your custom condition. } }
Demo
php doc/demo/run.php
koriym/dev-pdo-statement 适用场景与选型建议
koriym/dev-pdo-statement 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.66k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2016 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 koriym/dev-pdo-statement 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 koriym/dev-pdo-statement 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 koriym/dev-pdo-statement 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
VV database abstraction layer with query builder and DB structure models
VV DB Driver over PDO extension
Useful Query Builder, PDO Class for PHP. A simple access to your SQL records.
PostgreSQL
package library for help you to use database
统计信息
- 总下载量: 10.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-23