pahenrus/react-mysqli

React.PHP 的异步非阻塞 MySQL 驱动

1.0.5 2018-02-19 09:51 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:47:46 UTC


README

React.PHP提供异步非阻塞的 MySQLi 驱动。

需要php-mysqlnd 扩展

安装

composer require pahenrus/react-mysqli

示例

$loop = \React\EventLoop\Factory::create();

$makeConnection = function () {
    return mysqli_connect('localhost', 'vagrant', '', 'test');
};

$mysql = new \React\MySQLi\Client($loop, new \React\MySQLi\Pool($makeConnection, 10));

$mysql->query('select * from test')->then(
    function (\React\MySQLi\Result $result) {
        print_r($result->all());
    },
    function ($error) {
        error_log($error);
    }
);

$loop->run();