我正在使用LOAD DATA LOCAL INFILE函数将csv数据插入数据库。但是数据库中的某些值不正确。它不断合并一些列。enter image description here
例如,在所选行(201)中,列E和F作为" Noir satin?,19x9.5"插入到数据库中。而不是单独的值。我使用以下查询来插入数据。
// LOAD IN DATA FROM CSV TO FASTCO TABLE LATEST STARTS
$loadmeth = "'" . '"' . "'";
$loadindatasql = "LOAD DATA LOCAL INFILE '$current_date/FastcoWheelInventory.csv'
INTO TABLE xcart_wheels_temp_fastco
CHARACTER SET UTF8
FIELDS TERMINATED BY ','
ENCLOSED BY $loadmeth
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;";
db_query($loadindatasql);
$checkinsert = func_query("SELECT * FROM xcart_wheels_temp_fastco");
if (empty($checkinsert)) {
$loadindatasql = "LOAD DATA LOCAL INFILE '$current_date/FastcoWheelInventory.csv'
INTO TABLE xcart_wheels_temp_fastco
CHARACTER SET UTF8
FIELDS TERMINATED BY ','
ENCLOSED BY $loadmeth
LINES TERMINATED BY '\n'
IGNORE 1 LINES;";
db_query($loadindatasql);
}
func_query和db_queries是xcart中用于执行查询的函数。我用Google搜索,但没有得到提示。我期待着你的回复。 谢谢