Are there limitations in mysqli that make it unsuitable for use with AMP or ReactPHP?

184 Views Asked by At

I've seen that libraries such as amphp/mysql and friends-of-reactphp/mysql implement the low-level MySQL protocol, and do not rely on any built-in extension.

Given that mysqli supports async queries, is there any reason why these async libraries cannot be based on mysqli?

Originally asked as Why isn't amphp/mysql based on mysqli? (closed).

2

There are 2 best solutions below

1
WyriHaximus On BEST ANSWER

Hey ReactPHP core team member here. In short you shouldn't use them (you always can but we strongly advise against it) because their I/O isn't hooked into our event loop. Meaning it can block the entire loop and everything hooked into it until it's done with what ever it does.

0
BenMorel On

Courtesy @bwoebi on amphp/mysql's GitHub:

mysqli_poll() is just polling... mysql. It does not provide you any possibility to poll any other streams together with the mysql data. There's no underlying file descriptors exposed by mysqli which the event loop could use.