记录laravel走过的坑

chunk问题

记录laravel走过的坑_第1张图片
代码中chunk的搜索条件和更新条件一样时,会有部分数据无法更新。导致问题的原因是chunk分页取的数据page是+1,和实际的数据不符。看下源代码就明白
`
public function chunk($count, callable $callback)
{

$results = $this->forPage($page = 1, $count)->get();

while (count($results) > 0) {
    // On each chunk result set, we will pass them to the callback and then let the
    // developer take care of everything within the callback, which allows us to
    // keep the memory low for spinning through large result sets for working.
    if (call_user_func($callback, $results) === false) {
        return false;
    }

    $page++;

    $results = $this->forPage($page, $count)->get();
}

return true;

}`

遇到一个记录一个

你可能感兴趣的:(php,mysql,git,程序员)