dqc22586 2018-08-16 12:35
浏览 53

使用CI中的加载数据InFile上载500000条记录,但有时不会插入所有记录

I am uploading 500 000 records using load data InFile in CI but sometime all record inserted or sometime thousand records not inserted in same csv file.

Controller

public function upload_csv_test()
{
    $adminid = $this->session->userdata('aid');
    if(empty($adminid))
    {
        redirect('admin/index');
    }
    else
    { 
        $file_path = "/var/www/html/asset/test_csv/5Lac.csv";
        $sub = $this->Admin_model->add_csv_data($file_path);      
    } 
}

Model

public function add_csv_data($file_path)
{   

    $this->db->query("LOAD DATA LOCAL INFILE '".$file_path."' 
    INTO TABLE test_csv     
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '\
' 
    IGNORE 1 LINES
    (cid,latitude,longitude,Email,Personal_FirstName)
    ");

}
  • 写回答

1条回答 默认 最新

  • matlabmann 2018-08-16 15:56
    关注

    That functionality doesn't insert any data if the database would throw an error. Usually it is when a column has the wrong format like a date or decimal numbers.

    If you can detect one file on which it fails, take it, split it in smaller batches and look at the values. You could even transform it into a normal insert-command and test it with the failing data. Good luck!

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大