How to chunk results from a custom query in Laravel

前端 未结 8 1370
北海茫月
北海茫月 2020-12-17 18:37

I have a custom query that grabs data from the old system and maps it to models in the new system. The query looks like this:

$companies = DB::connection(\'leg

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 19:23

    I believe you can use chunk on a query builder. E.g.

    DB::connection('legacy')->select("...")->chunk(200, function($companies){
        //do something with $companies
    });
    

提交回复
热议问题