它可以工作,但是当我在 CSV 文件中导入近 2500 多行的大文件时,它加载/导入速度很慢,并且说错误,但有些文件正在插入,有些则没有。我的问题是有没有办法让它更快导入?我在文件中看到但我不知道如何使用它。
代码:
function convert_csv($id){
if (empty($id)) redirect("contracts");
$config['upload_path'] = './files/contracts-csv/';
$config['allowed_types'] = 'csv';
$config['max_size'] = '4096';
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
$this->upload->display_errors('', '');
if (!$this->upload->do_upload("csv_file")) {
echo $this->upload->display_errors(); die();
$this->data['error'] = array('error' => $this->upload->display_errors());
} else {
$upload_result = $this->upload->data();
$upload_result = $this->upload->data();
$this->load->library('csvreader');
$result = $this->csvreader->parse_file("./files/contracts-csv/".$upload_result['file_name']);
$date_today = date('Y-m-d H:i:s');
foreach ($result as $v) {
$this->contract_items->add_serial($v,$id,$date_today);
}
}
}