https://github.com/tonix-tuft/reactphp-mysql-decorator
A decorator of the ReactPHP MySQL connection interface which augments its behaviour, e.g. providing binding of associative parameters.
https://github.com/tonix-tuft/reactphp-mysql-decorator
mysql php reactphp
Last synced: 4 days ago
JSON representation
A decorator of the ReactPHP MySQL connection interface which augments its behaviour, e.g. providing binding of associative parameters.
- Host: GitHub
- URL: https://github.com/tonix-tuft/reactphp-mysql-decorator
- Owner: tonix-tuft
- License: mit
- Created: 2019-05-28T16:36:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T00:02:32.000Z (about 3 years ago)
- Last Synced: 2025-09-17T23:59:15.526Z (4 months ago)
- Topics: mysql, php, reactphp
- Language: PHP
- Homepage:
- Size: 404 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ReactPHP MySQL Decorator
A decorator of the [ReactPHP MySQL](https://github.com/friends-of-reactphp/mysql) connection interface which augments its behaviour, e.g. providing binding of associative parameters.
## Installation
Using [Composer](https://getcomposer.org/):
```
composer require tonix-tuft/reactphp-mysql-decorator
```
## Usage
Currently, the only available decorator is `BindAssocParamsConnectionDecorator`, which provides the binding of associative parameters like in standard PHP `PDO` objects.
### BindAssocParamsConnectionDecorator
This decorator allows the binding of associative parameters in queries (named parameters). To use it just wrap a `React\MySQL\ConnectionInterface`:
```php
createLazyConnection($uri); // returns a React\MySQL\ConnectionInterface
$connectionWithBindAssocParams = new BindAssocParamsConnectionDecorator($connection);
// Now you can bind associative parameters when you execute your queries.
$value = 123;
$connectionWithBindAssocParams->query('SELECT * FROM table WHERE field = :value', [
':value' => $value
])->then(
// ...
);
```
## Acknowledgements
[friends-of-reactphp/mysql](https://github.com/friends-of-reactphp/mysql) - Async MySQL database client for ReactPHP.
## License
MIT © [Anton Bagdatyev (Tonix)](https://github.com/tonix-tuft)