Need help with mysql?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

amphp
251 Stars 44 Forks Other 351 Commits 14 Opened issues

Description

Async MySQL client for PHP based on Amp.

Services available

!
?

Need anything else?

Contributors list

mysql

Build Status Code Coverage Release License

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 = :id");

/** @var \Amp\Mysql\ResultSet $result */
$result = yield $statement->execute(['id' => 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

[email protected]
instead of using the issue tracker.

License

The MIT License (MIT). Please see

LICENSE
for more information.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.