定制 amphp/mysql 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amphp/mysql

最新稳定版本:v3.0.0

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 client transparently distributes these queries across a scalable pool of available connections and does so using 100% userland PHP; 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.

统计信息

  • 总下载量: 997.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 378
  • 点击次数: 1
  • 依赖项目数: 27
  • 推荐数: 0

GitHub 信息

  • Stars: 377
  • Watchers: 21
  • Forks: 62
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-02