本文整理汇总了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);
}