我有一个附属窗口 CSV,它有近 1 个 lac 行,我想将它保存为节点,我尝试使用批处理 API。
但我仍然收到php超时错误..请帮助
function MODULE_aw_batch(){
$operations = array();
$csv = file_directory_path().'/aw/datafeed_134642.csv';
$file = fopen($csv, 'r');
while (($data = fgetcsv($file)) !== FALSE) {
$operations[] = array('MODULE_aw_op', array($data));
}
$batch = array(
'title' => t('Generating feeds'), // Title to display while running.
'operations' => $operations,
'finished' => 'MODULE_aw_finished', // Last function to call.
'init_message' => t('Importing...it may take 4-5 hours'),
'progress_message' => t('Processed @current out of @total.'),
'error_message' => t('Import feeds has encountered an error.'),
);
batch_set($batch);
batch_process('admin/content/node/overview');
}
更新(已解决)
而不是一次读取整个 csv 文件,而是将 csv 拆分为每个进程读取 5 行