CSV Import honouring fieldnames in first line

Issue #398 new
Chris Jeffries created an issue

I needed CSV import to honour the feildnames in the header row, so I made a small alteration. Would be nice if this was part of the main code. $number_of_cols is reset to the number of columns in the data to allow for unimported columns (eg autoincremented primary key fields). It should still barf on missing NOT NULL fields (not tested).

Line 5700:
-continue;
+ {$fieldnames= ' (`' . implode('`, `', $csv_data).'`) '; $number_of_cols = count($csv_data); continue; } else {$fieldnames = '';} echo "[$fieldnames]";

Line 5702:
- $csv_insert .= "INSERT INTO ".$this->quote_id($table) . " VALUES (";
+ csv_insert .= "INSERT INTO ".$this->quote_id($table) . $fieldnames . " VALUES (";

Comments (0)

  1. Log in to comment