-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,17 @@ | |
|
||
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 allows to dynamically query a server with 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). | ||
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) | ||
- *Full* MySQL protocol support including *all*<sup>†</sup> available commands asynchronously | ||
- 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*<sup>†</sup> available commands asynchronously | ||
|
||
<sup>† As documented in [official Mysql Internals Manual](https://dev.mysql.com/doc/internals/en/client-server-protocol.html)</sup> | ||
|
||
|
@@ -22,22 +24,29 @@ This package can be installed as a [Composer](https://getcomposer.org/) dependen | |
composer require amphp/mysql | ||
``` | ||
|
||
This package requires PHP 8.1 or later. | ||
## Requirements | ||
|
||
- PHP 8.1+ | ||
|
||
## Usage | ||
|
||
More extensive code examples reside in the [`examples`](examples) directory. | ||
|
||
```php | ||
$config = Amp\Mysql\MysqlConfig::fromString( | ||
"host=127.0.0.1 user=username password=password db=test" | ||
use Amp\Mysql\MysqlConfig; | ||
use Amp\Mysql\MysqlConnectionPool; | ||
|
||
$config = MysqlConfig::fromString( | ||
"host=localhost user=username password=password db=test" | ||
); | ||
|
||
$pool = new Amp\Mysql\MysqlConnectionPool($config); | ||
$pool = new MysqlConnectionPool($config); | ||
|
||
$statement = $pool->prepare("SELECT * FROM table_name WHERE id = :id"); | ||
foreach ($statement->execute(['id' => 1337]) as $row) { | ||
// $row is an associative array of column values. e.g.: $row['column_name'] | ||
|
||
$result = $statement->execute(['id' => 1337]); | ||
foreach ($result as $row) { | ||
// $row is an associative-array of column values, e.g.: $row['column_name'] | ||
} | ||
``` | ||
|
||
|
@@ -47,7 +56,7 @@ foreach ($statement->execute(['id' => 1337]) as $row) { | |
|
||
## Security | ||
|
||
If you discover any security related issues, please email [`[email protected]`](mailto:[email protected]) instead of using the issue tracker. | ||
If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker. | ||
|
||
## License | ||
|
||
|