📜  laravel 查询获取大表记录 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:06.080000             🧑  作者: Mango

代码示例1
#METHOD 1
DB::table('users')->orderBy('id')->chunk(100, function ($users) {
    foreach ($users as $user) {
        //
    }
});

#METHOD 2
foreach (DB::table('users')->orderBy('id')->cursor() as $flight) {
    //
}