PHPackages                             johncurt/async-mysql - 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. [Database &amp; ORM](/categories/database)
4. /
5. johncurt/async-mysql

ActiveLibrary[Database &amp; ORM](/categories/database)

johncurt/async-mysql
====================

AsyncMySQL - Asynchronous MySQL Query Manager

0.1.3(8y ago)67.1k↓36.8%1Apache-2.0PHPPHP &gt;=7.0

Since Mar 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/johncurt/async-mysql)[ Packagist](https://packagist.org/packages/johncurt/async-mysql)[ RSS](/packages/johncurt-async-mysql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

AsyncMySQL - Asynchronous MySQL Query Manager
=============================================

[](#asyncmysql---asynchronous-mysql-query-manager)

AsyncMySQL helps manage several asynchronous queries with callbacks on success or failure. It can be used by itself to speed up concurrent queries in a single model, or in conjunction with an asynchronous library such as Amp or Ratchet.

Background
----------

[](#background)

This library uses mysqli::poll to check for completed queries in its query pool. Once a query is completed it calls the appropriate callback. This library requires you have mysqli and mysqlnd installed. Only mysqlnd supports the mysqli\_poll function.

Installation
------------

[](#installation)

`composer require johncurt/async-mysql`

Usage
-----

[](#usage)

First instantiate a ConnectionManager. This is the class that connects the queries to a database (one connection per query) and polls the connections to see if they are ready to be reaped. Pass all of your connection data into it.

`$conn = new \JohnCurt\AsyncMySQL\ConnectionManager('127.0.0.1', 'user', 'pass', 'schema', 3306);`

Then you instantiate a Query for each query that you will be attaching. Be sure to pass in callbacks (or null if no callback is needed), making use of the `use` construct to gain access to variables outside the scope of the callback.

```
$success1 = function(\mysqli_request $request) use (&$request1) { $request1 = $request;};

$failure1 = function(string $error) use (&$error1) { $error1 = $error;};

$query = new \JohnCurt\AsyncMySQL\Query('SELECT * FROM table WHERE 1', $success1, $failure1);

```

Once the query is instantiated, you can send it off for processing:

`$conn->runQuery($query);`

You can add as many as you want. When you are ready to get some results, You can either have the ConnectionManager just reap the ones that are ready or you can make a blocking call to wait for everything to come back. Regardless, all of the queries are (have been) run in separate connections, asynchronously.

`$conn->reapAny();`

or

`$conn->reapAll();` (blocking)

You can also pass in a timeout to the `reapAll` method that will cause it to stop waiting for queries to finish after the prescribed seconds.

Contact
-------

[](#contact)

Feel free to reach out if you have any questions! You can find my personal website at \[\] or my PHP blog at \[\]. I would love to hear your comments as well as about any bugs you might find.

License
-------

[](#license)

Copyright 2018 John C. Fansler

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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 ~0 days

Total

4

Last Release

2990d ago

PHP version history (3 changes)0.1.0PHP ~7.1

0.1.1PHP ~7.0

0.1.2PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1fbaefd345d489abfefc37a82a981effc5f0d7d971396ee10dd7ac8bee7beaa?d=identicon)[johncurt](/maintainers/johncurt)

---

Top Contributors

[![johncurt](https://avatars.githubusercontent.com/u/7644751?v=4)](https://github.com/johncurt "johncurt (11 commits)")

---

Tags

asyncasynchronousmysqlsqlasync-mysql

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[catfan/medoo

The lightweight PHP database framework to accelerate development

4.9k1.5M194](/packages/catfan-medoo)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[greenlion/php-sql-parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

63911.6M82](/packages/greenlion-php-sql-parser)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)

PHPackages © 2026

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