一个用于 PHP 的异步 MySQL 客户端,可通过高效的非阻塞功能优化数据库交互。非常适用于响应速度快、性能高的应用程序。
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.).
† As documented in official Mysql Internals Manual
This package can be installed as a Composer dependency.
composer require amphp/mysqlMore 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']
}amphp/mysql follows the semver semantic versioning specification like all other amphp packages.
If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.
The MIT License (MIT). Please see LICENSE for more information.
暂无开放 Issues,或尚未同步最近议题。