gpt4 book ai didi

excel - maatwebsite/excel 使用 block 导入似乎不起作用 - Laravel 5.4

转载 作者:行者123 更新时间:2023-12-04 20:32:42 25 4
gpt4 key购买 nike

我按照文档进行操作,队列执行得很好,但是第一次之后的数据没有存储到数据库中(对于代码示例,我正在编写一个单独的文件)。请引用下面我的代码。

包版本:2.1.0
Laravel 版本:5.4.36

Excel::filter('chunk')->load(storage_path('users.csv'))->
chunk(250,function($results){
$row_set = $results->toArray();
foreach ($row_set as $key => $row) {
Storage::disk('local')->put(rand(10, 100).'_users.txt', json_encode($row));
}
});

配置:
php.ini -> auto_detect_line_endings:真
导出.php
force_sheets_collection:真,
QUEUE_DRIVER=数据库

请帮我解决这个问题,我花了大约 2 天的时间在不同的错误报告和解决方案中找到解决方案。

最佳答案

您应该将 $results 设置为函数,还需要通过在 foreach 循环中放置 Log::debug() 消息来确保

Excel::filter('chunk')->load(storage_path('users.csv'))->
chunk(250,function($results){
foreach ($results as $key => $row) {
Storage::disk('local')->put(rand(10, 100).'_users.txt', json_encode($row));
}
});

关于excel - maatwebsite/excel 使用 block 导入似乎不起作用 - Laravel 5.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47643310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com