老师您好 我这边在处理协程 mysql时出现报错 (上部分报错 下部分 代码 )是需要修改什么配置吗
来源:5-5 异步Mysql详解(上)
1652833140
2019-08-06
[root@swoole io]# php sql.php
PHP Fatal error: Uncaught Swoole\Error: operation not support (reactor is not ready) in /root/study/work/demo/io/sql.php:4
Stack trace:
#0 /root/study/work/demo/io/sql.php(4): Swoole\Coroutine\MySQL->connect(Array)
#1 {main}
thrown in /root/study/work/demo/io/sql.php on line 4
Fatal error: Uncaught Swoole\Error: operation not support (reactor is not ready) in /root/study/work/demo/io/sql.php:4
Stack trace:
#0 /root/study/work/demo/io/sql.php(4): Swoole\Coroutine\MySQL->connect(Array)
#1 {main}
thrown in /root/study/work/demo/io/sql.php on line 4
[root@swoole io]# cat sql.php
<?php
$swoole_mysql = new Swoole\Coroutine\MySQL();
$swoole_mysql->connect([
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'root',
'password' => '',
'database' => 'swoole',
]);
$res = $swoole_mysql->query('select * from test where id = 1');
?>
写回答
1回答
-
您好。用这个试试 Swoole\Coroutine::create()
042019-08-07
相似问题