amphp / mysql
Asynchronous MySQL client for PHP based on Amp.
Fund package maintenance!
amphp
Installs: 739 185
Dependents: 26
Suggesters: 0
Security: 0
Stars: 361
Watchers: 23
Forks: 62
Open Issues: 7
Requires
- php: >=8.1
- amphp/amp: ^3
- amphp/parser: ^1.1
- amphp/pipeline: ^1
- amphp/socket: ^2.2
- amphp/sql: ^2
- amphp/sql-common: ^2
Requires (Dev)
- ext-mysqli: *
- ext-openssl: *
- amphp/file: ^3
- amphp/php-cs-fixer-config: ^2
- amphp/phpunit-util: ^3
- amphp/process: ^2
- phpbench/phpbench: ^1.2.6
- phpunit/phpunit: ^9
- psalm/phar: 5.23
- 3.x-dev
- v3.0.0
- v3.0.0-beta.9
- v3.0.0-beta.8
- v3.0.0-beta.7
- v3.0.0-beta.6
- v3.0.0-beta.5
- v3.0.0-beta.4
- v3.0.0-beta.3
- v3.0.0-beta.2
- v3.0.0-beta.1
- 2.x-dev
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.0
- v2.0.0-rc1
- v1.x-dev
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- v0.3.1
- v0.3.0
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
This package is auto-updated.
Last update: 2024-12-10 19:18:43 UTC
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.