-1
我想直接從assets/temp/filename批量插入一個csv文件到mysql表users_csv_import。試圖用代碼點火器批量插入csv文件
我得到mysql語法錯誤,我找不到它。
function bulk_insert_file($filename) {
$file_location = 'assets/temp/'.$filename;
$sql = "LOAD DATA INFILE '".$file_location."' INTO TABLE users_csv_import
TERMINATED BY '\r\n'";
$this->db->query($sql);
}
收到此錯誤:
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TERMINATED BY ' '' at line 2
LOAD DATA INFILE 'assets/temp/new_users_template24.csv' INTO TABLE users_csv_import TERMINATED BY ' '
Filename: C:\Program Files (x86)\Ampps\www\system\database\DB_driver.php
行號:330
你必須檢查你的查詢有一些語法錯誤是$這個 - > DB-> last_query(),並嘗試手動執行,看看糾正錯誤 – Sundar
@ saurabh2836什麼不明白嗎?查詢語法錯誤,它寫在錯誤消息 –