怪我咯2017-06-12 09:22:44
不知道具體的使用場景,不敢瞎BB
BB一下
取出一個大數組之後
$res = [];
for ($x=0; $x<=($res/500); $x++) {
$res = array_slice($res,0+500*$x,500);
if($res)
{
update table set=value where id($res['id']);修改数据库
foreach($res as $key=>$value)
{
$res[$key]['某值'] = ‘某值’;
}
}
}
学习ing2017-06-12 09:22:44
1.如果是同一張表,並且有某種相同特徵某些數據可以使用where條件批量更新
update table set count=count+1 where id > 1 and id < 501
2.如果不同的表,且邏輯也不一樣,那要考慮是否會超時了,如果無需用戶買單的請求,可以採用fastcgi_finish_request
中斷用戶請求,再繼續執行代碼,或者採取定時任務的形式