amphp/mysql
Composer 安装命令:
composer require amphp/mysql
包简介
Asynchronous MySQL client for PHP based on Amp.
README 文档
README
AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind.
amphp/mysql is an asynchronous MySQL client.
The library implements concurrent querying by transparently distributing queries across a scalable pool of available connections. The MySQL client protocol is implemented using 100% PHP code; there are no external extension dependencies (e.g. ext/mysqli, ext/pdo, etc.).
Features
- Exposes a non-blocking API for issuing multiple MySQL queries concurrently
- Transparent connection pooling to overcome MySQL's fundamentally synchronous connection protocol
- MySQL transfer encoding support (gzip, TLS encryption)
- Support for parameterized prepared statements
- Nested transactions with commit and rollback event hooks
- Unbuffered results to reduce memory usage for large result sets
- Full MySQL protocol support including all† available commands asynchronously
† As documented in official Mysql Internals Manual
Installation
This package can be installed as a Composer dependency.
composer require amphp/mysql
Requirements
- PHP 8.1+
Usage
More extensive code examples reside in the examples directory.
use Amp\Mysql\MysqlConfig; use Amp\Mysql\MysqlConnectionPool; $config = MysqlConfig::fromString( "host=localhost user=username password=password db=test" ); $pool = new MysqlConnectionPool($config); $statement = $pool->prepare("SELECT * FROM `table_name` WHERE `id` = :id"); $result = $statement->execute(['id' => 1337]); foreach ($result as $row) { // $row is an associative-array of column values, e.g.: $row['column_name'] }
Versioning
amphp/mysql follows the semver semantic versioning specification like all other amphp packages.
Security
If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.
License
The MIT License (MIT). Please see LICENSE for more information.
amphp/mysql 适用场景与选型建议
amphp/mysql 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.13M 次下载、GitHub Stars 达 376, 最近一次更新时间为 2015 年 05 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 amphp/mysql 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amphp/mysql 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.13M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 377
- 点击次数: 23
- 依赖项目数: 29
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-02