How to use chunkById with a custom order?
Hi all!
Currently, it seems it's not possible to use chunkById with a custom order, other than by id.
Has anyone of you figured out a workaround?
Well, that's the whole point of it isn't it?
Do you really need chunkById or is chunk enough?
The whole point of it is to not skip any records when the query's where clauses get affected.
So I'm required to use chunkById, instead of just chunk.
I went ahead with a workaround using a do-while loop and keeping track of the processed id's myself. 👍
Why would chunk make you skip records?
@dirksamson if you have a where and you do an update on the where column.
example:
User::where('active', 1)->chunk(100, function ($users) {
$users->each(function ($user) {
$user->update('active', 0);
});
});
Please or to participate in this conversation.