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);//写入数据到管道  
}
阅读 2.1k
1 个回答

你这不是类方法吧?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题