本文整理汇总了PHP中Statement::chunk方法的典型用法代码示例。如果您正苦于以下问题:PHP Statement::chunk方法的具体用法?PHP Statement::chunk怎么用?PHP Statement::chunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement::chunk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* Loop through all statements and create a new key in the document route.
* This key 'convertedTimestamp' is the same as the statement timestamp but in a
* data format the MongoDB aggregation function needs.
*
* @return string
*/
public function fire()
{
Statement::chunk(1000, function ($statements) {
foreach ($statements as $s) {
$s->timestamp = new \MongoDate(strtotime($s->statement['timestamp']));
$s->save();
}
$this->info(count($statements) . ' converted.');
});
$this->info('All finished, hopefully!');
}
示例2: up
public function up()
{
Statement::chunk(1000, function ($statements) {
foreach ($statements as $statement) {
if (is_object($statement->refs) || is_array($statement->refs) && isset($statement->refs['id'])) {
$statement->refs = [$statement->refs];
$statement->save();
}
}
echo count($statements) . ' converted.';
});
echo 'All finished, hopefully!';
}