Worker::runAll() 執行前不能運行資料庫,放在 ->onWorkerStart 即可
--
6,017 total views, 1 views today
Worker::runAll() 執行前不能運行資料庫,放在 ->onWorkerStart 即可
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$worker = new Worker('websocket://0.0.0.0:1234'); $worker->onWorkerStart = function () { global $database; $database = new Medoo($db_conf); $datas = $database->select("bots", "*", ["widget"=>$connection->token]); .... }; $worker->onMessage = function($connection, $data){ global $database; $database->select(...); }; ... Worker::runAll(); |
--
6,017 total views, 1 views today