Skip to content

Repository files navigation

mysql

Build StatusCode CoverageReleaseLicense

Async MySQL client built with Amp.


amp/mysql is an asynchronous MySQL client built on the Amp concurrency framework. The library exposes a Promise-based API to dynamically query multiple MySQL connections concurrently. 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

  • Asynchronous API exposing full single-threaded concurrency
  • Transparent connection pooling to overcome MySQL's fundamentally synchronous connection protocol
  • MySQL transfer encoding support (gzip, TLS encryption)
  • Support for all MySQL commands

† As documented in official Mysql Internals Manual

Project Goals

  • Expose a non-blocking API for issuing multiple MySQL queries in parallel
  • Support the full MySQL protocol and all available commands asynchronously

Installation

This package can be installed as a Composer dependency.

composer require amphp/mysql

Requirements

Documentation & Examples

More extensive code examples reside in the examples directory.

\Amp\Loop::run(function() {
$config = Amp\Mysql\ConnectionConfig::fromString("host=127.0.0.1 user=username password=password db=test");
/** @var \Amp\Mysql\Pool $pool */$pool = Amp\Mysql\pool($config);
/** @var \Amp\Mysql\Statement $statement */$statement = yield$pool->prepare("SELECT * FROM table_name WHERE id=?");
/** @var \Amp\Mysql\ResultSet $result */$result = yield$statement->execute([1337]);
while (yield$result->advance()) {
$row = $result->getCurrent();
// $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 email contact@amphp.org instead of using the issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.

About

Async MySQL client for PHP based on Amp.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages