本文整理匯總了PHP中Illuminate\Database\Query\Builder::chunk方法的典型用法代碼示例。如果您正苦於以下問題:PHP Builder::chunk方法的具體用法?PHP Builder::chunk怎麽用?PHP Builder::chunk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Database\Query\Builder
的用法示例。
在下文中一共展示了Builder::chunk方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: it_load_events_for_aggregate
/**
* @test
*/
public function it_load_events_for_aggregate()
{
$aggregateRootId = new BarId('BarId');
$this->db->table('events')->willReturn($this->queryBuilder);
$this->queryBuilder->where('aggregate_root_id', 'BarId')->willReturn($this->queryBuilder);
$this->queryBuilder->chunk(1000, Argument::any())->willReturn(true);
$this->eventStore->load($aggregateRootId);
}
示例2: getEventStream
/**
* @param Builder $builder
* @return EventStreamInterface
*/
protected function getEventStream(Builder $builder)
{
$events = [];
$builder->chunk(1000, function ($dbEvents) use(&$events) {
array_push($events, ...array_map(function ($dbEvent) {
$dbEvent = (array) $dbEvent;
/** @var EventInterface $eventClass */
$eventClass = $dbEvent['type'];
$payload = $this->serializer->deserialize($dbEvent['payload']);
$payload['id'] = $dbEvent['aggregate_root_id'];
return $eventClass::createFromPayload($payload);
}, $dbEvents));
});
return new EventStream(...$events);
}