Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MYSQLI_ASYNC available with prepared statements in PHP?

Utilizing the MySQL Native Driver, you can use the MYSQLI_ASYNC flag with the mysqli_query function to make parallel, asynchronous MySQL DB calls.

I get how all that works, but what I'd really like to be able to do is somehow use the MYSQLI_ASYNC flag with the prepared statement set of functions in PHP.

Is this possible, and if so, how?

like image 806
HartleySan Avatar asked Sep 05 '25 03:09

HartleySan


1 Answers

It is not possible to use MYSQLI_ASYNC with prepared statements.

The asynchronous functionality (mysqli_poll() & mysqli_reap_async()) was developed as kind of an experimental feature. It was never fully finished, and it's not super stable either. There have been suggestions to finally finish this feature, which some claim could be the only advantage over PDO, but there is not enough interest in this feature to finish it.

You would be much better off with a proper async solution that isn't mysqli specific. There are number of libraries available and the fibers PHP extension that can allow you to achieve this feature. After all, it's not really anything specific to MySQL or mysqli.

like image 50
Dharman Avatar answered Sep 07 '25 23:09

Dharman