I have one csv file which has n number of records. Now I want to import it into table. I also want to ignore duplicate records(Duplicate wil considred if specific two column has the same value). I am also passing the headers into query value so that reoced will be inserted into appropriate column of database table
My query is $header is csv header $basePath is base path location of csv
$query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE table name FIELDS TERMINATED BY '`' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n' (duplicatematchcol1,duplicatematchcol1) IGNORE 0 LINES (" . implode(',', $header) . ") , addslashes($basePath));