swoole 子进程中调用$this 报错
用PHP CI 结合Swoole
$process = new swoole_process("total_income", true);
$process->start();
$process->write(json_encode(array('accountid'=>$row->accountid,'period'=>$row->period)));
function total_income(swoole_process $worker)
{
$data = json_decode($worker->read());
$accountid = $data['accountid'];
$period = $data['period'];
$_this = $data['this'];
$query_sub = $this->db->query("SELECT SUM(curcredit) AS curcredit FROM tb_subjectbalance WHERE accountid=? AND period BETWEEN ? AND ? AND subjectid LIKE '6001%'", array($accountid, $first_period, $prev_period));
$income = $query_sub->row()->curcredit;
if($income > 4000000)
{ $this->db->trans_start();
$this->db->query("INSERT INTO tb_testing_result(id,teamid,accountid,itemid, period,status) VALUES(?,?,?,?,?,?)", array(trxid(),1,$accountid,3,$period,"145010"));
$this->db->trans_complete();
}
$worker->write(1);//写入数据到管道
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你这不是类方法吧?