当我使用邮递员从块中获取结果时,结果将返回空,我该如何解决呢?
这是我的代码
public function downloadMemberInfo()
{
error_log('download');
set_time_limit(240); //testing
$memberListsArray = array();
Member::select('vipcode')->where('vipcode','!=','')
->chunk(3000,function($members) use($memberListsArray){
foreach($members as $member){
$memberListsArray[] = $member;
}
});
return response()->json($memberListsArray);
}
答案 0 :(得分:0)
使用get
之前,您需要先致电chunk
; because chunk
works with collections。尝试下一个代码。
public function downloadMemberInfo()
{
error_log('download');
set_time_limit(240);
$members = Member::select('vipcode')
->where('vipcode', '!=', '')
->get()
->chunk(3000)
->toArray();
return response()->json($members);
}