Asynchronous ActiveRecord

Hello. I use RatchetPHP socket server on php. My server works with mysql but I can see this problem: mysql queries work synchronously - one query waits for another. I use ActiveRecord to do this. How to solve this problem? Will pcntl_fork() help? If so - please give examples. Or how can mysql can be done Asynchronously?

1 Like

By implementing protocol yourself such as https://github.com/bixuehujin/reactphp-mysql

1 Like

I found mysqlnd extension with non-blocking queries feature. It works only for mysqli. So can ActiveRecord use mysqli instead of PDO?

1 Like

It can if you’ll implement a driver.

1 Like

Can you give some advices\articles how or where to do it?

1 Like

It would be something like https://github.com/sfedosimov/yii2-oci8pdo or https://github.com/apaoww/yii2-oci8 but using mysqli instead of oci8.

1 Like

Thanks. Will look

1 Like