用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);//写入数据到管道
}
你这不是类方法吧?