PHPackages                             jenner/async-mysql-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. jenner/async-mysql-php

ActivePackage[Queues &amp; Workers](/categories/queues)

jenner/async-mysql-php
======================

php mysql async client

v0.2(10y ago)411.0k10MITPHPPHP &gt;=5.3.0

Since Jul 23Pushed 5y ago5 watchersCompare

[ Source](https://github.com/huyanping/async-mysql-php)[ Packagist](https://packagist.org/packages/jenner/async-mysql-php)[ RSS](/packages/jenner-async-mysql-php/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

async-mysql-php
===============

[](#async-mysql-php)

async mysql client
[中文README](https://github.com/huyanping/async-mysql-php/blob/master/README.ZH.MD)
Doc：[async-mysql-php](http://www.huyanping.cn/php%E5%BC%82%E6%AD%A5%E5%B9%B6%E5%8F%91%E8%AE%BF%E9%97%AEmysql%E7%AE%80%E5%8D%95%E5%AE%9E%E7%8E%B0/)

Import
------

[](#import)

`composer require jenner/async-mysql-php`
Or
`require /path/to/async-mysql-php/autoload.php`

Details
-------

[](#details)

- based on `mysqli::poll`
- throw `RuntimeException` when mysql connection or sql is error
- the return value's order is same to the order that you call `attach` method
- every `attach` method will return a `Promise` object, you can call `Process::then` method to defer the data processing.

Interface
---------

[](#interface)

- attach(),submit async mysql task
- isDone(),check all the task whether complete
- execute(), get the result

History
-------

[](#history)

- add `isDone` method to check whether complete. it will check every thousand microsecond.
- add `react/promise` package for asynchronous processing data.

Notice
------

[](#notice)

The async object will send the request to when you call the `attach` method. mysql server. Actually the async object will just check all the task whether complete and return result, when you call `execute` method.So you can do anything you want between `attach` and `execute`, for example:request a url and call `execute`after the request is done.

example:

```
try{
    $async_mysql = new \Jenner\Mysql\Async();
    $async_mysql->attach(
        ['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test', 'port'=>3306],
        'select * from stu'
    );
    $async_mysql->attach(
        ['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test', 'port'=>3306],
        'select * from stu limit 0, 3'
    );
    $result = $async_mysql->execute();
    print_r($result);
}catch (Exception $e){
    echo $e->getMessage();
}
```

use promise:

```
try {
    $async_mysql = new \Jenner\Mysql\Async();
    $promise_1 = $async_mysql->attach(
        ['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test'],
        'select * from stu'
    );
    $promise_1->then(
        function ($data) {
            echo 'sucess:' . var_export($data, true) . PHP_EOL;
        },
        function ($info) {
            echo "error:" . var_export($info, true);
        }
    );
    $promise_2 = $async_mysql->attach(
        ['host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'database' => 'test'],
        'select * from stu limit 0, 3'
    );
    $promise_2->then(
        function ($data) {
            echo 'sucess:' . var_export($data, true) . PHP_EOL;
        },
        function ($info) {
            echo "error:" . var_export($info, true);
        }
    );
    $async_mysql->execute();
} catch (Exception $e) {
    echo $e->getMessage();
}
```

performance tests
-----------------

[](#performance-tests)

Summary:async-mysql is really faster than sync-mysql.
Based on the performance test result, async-mysql can improve performance. How much it can improve is depend on what your code want to do. In general case, the execution time is depend on the most complex sql. The memory used will be improved because the async-mysql will get all the result at the same time.

```
# 同步
[root@iZ942077c78Z async-mysql-php]# php tests/performance_sync.php
------------------------------------------
mark:[total diff]
time:4.2648551464081s
memory_real:18944KB
memory_emalloc:18377.171875KB
memory_peak_real:28416KB
memory_peak_emalloc:27560.3828125KB
[root@iZ942077c78Z async-mysql-php]# php tests/performance_sync.php
------------------------------------------
mark:[total diff]
time:4.2285549640656s
memory_real:18944KB
memory_emalloc:18377.171875KB
memory_peak_real:28416KB
memory_peak_emalloc:27560.3828125KB
[root@iZ942077c78Z async-mysql-php]# php tests/performance_async.php
------------------------------------------
mark:[total diff]
time:1.455677986145s
memory_real:38144KB
memory_emalloc:32574.015625KB
memory_peak_real:66816KB
memory_peak_emalloc:65709.7734375KB
# 异步
[root@iZ942077c78Z async-mysql-php]# php tests/performance_async.php
------------------------------------------
mark:[total diff]
time:1.8936941623688s
memory_real:38144KB
memory_emalloc:32574.015625KB
memory_peak_real:66816KB
memory_peak_emalloc:65709.7734375KB
[root@iZ942077c78Z async-mysql-php]# php tests/performance_async.php
------------------------------------------
mark:[total diff]
time:1.5208158493042s
memory_real:38144KB
memory_emalloc:32574.015625KB
memory_peak_real:66816KB
memory_peak_emalloc:65709.7734375KB
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~133 days

Total

2

Last Release

3865d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d132b55d12cd603f8cce9c152999e2b3f98748d56fe8a21adf62d5830d88d87?d=identicon)[huyanping](/maintainers/huyanping)

---

Top Contributors

[![white-poto](https://avatars.githubusercontent.com/u/4362540?v=4)](https://github.com/white-poto "white-poto (83 commits)")

---

Tags

phpasyncmysql client

### Embed Badge

![Health badge](/badges/jenner-async-mysql-php/health.svg)

```
[![Health](https://phpackages.com/badges/jenner-async-mysql-php/health.svg)](https://phpackages.com/packages/jenner-async-mysql-php)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.6M31](/packages/league-geotools)[clue/socks-react

Async SOCKS proxy connector client and server implementation, tunnel any TCP/IP-based protocol through a SOCKS5 or SOCKS4(a) proxy server, built on top of ReactPHP.

1191.1M33](/packages/clue-socks-react)[toin0u/geotools

Geo-related tools PHP 7.3+ library

1.4k1.3k](/packages/toin0u-geotools)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

113163.3k1](/packages/clue-docker-react)[clue/reactphp-eventsource

Instant real-time updates. Lightweight EventSource client receiving live messages via HTML5 Server-Sent Events (SSE). Fast stream processing built on top of ReactPHP's event-driven architecture.

5819.9k3](/packages/clue-reactphp-eventsource)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
