amphp / mysql

An async MySQL client for PHP, optimizing database interactions with efficient non-blocking capabilities. Perfect for responsive, high-performance applications.
Other
358 stars 63 forks source link

Transaction Support #24

Closed kelunik closed 6 years ago

kelunik commented 7 years ago

There should be examples for transactions and probably a dedicated API.

shtse8 commented 6 years ago

Any updates?

kelunik commented 6 years ago

Not yet, feel free to make an API suggestion.

shtse8 commented 6 years ago

$connection = $mysqlPool->getConnection();

$connection->query();

$connection->release();

$connection->beginTransaction();

$connection->commit();

$connection->rollback();

$connection = $mysqlPool->beginTransaction();

Example Usage:

$connection = $mysqlPool->beginTransaction();
$connection->query("SELECT 1");
$connection->commit();
$connection->release();

or

$connection = $mysqlPool->getConnection();
$connection->beginTransaction();
$connection->query("SELECT 1");
$connection->commit();
$connection->release();
kelunik commented 6 years ago

@trowski This has been implemented, no?

bwoebi commented 6 years ago

@kelunik Yes, it was. See e.g. https://github.com/amphp/mysql/blob/master/examples/6-transaction.php