I'm trying to import a CSV file into a mysql table. The entire database has a utf8_unicode_ci encoding. The CSV file also has an UTF8 encoding. But when I try to run the following it just shows blank characters in the table instead of the special character:
$query = "LOAD DATA LOCAL INFILE 'mycsvfile.csv' INTO TABLE location_temp
CHARACTER SET UTF8
FIELDS TERMINATED BY ';'
ENCLOSED BY '\"'
LINES TERMINATED BY '\r\n'";
$parameters = array ();
$connection->QueryExec ( $query, $parameters ); //Connection class
In the table above I only have one column location, the content of the csv file is: "ä";
I've also tried to change the value of the csv to "testthät";
in the table then comes: testth
it just skips after the special character.
EDIT: This is how I create my database connection:
try {
$this->conn = new PDO ( "mysql:host=" . $host . ";charset=utf8;dbname=" . $database, $user, $pass );
$this->conn->exec ( "set names utf8" );
} catch ( PDOException $e ) {
echo "Something went wrong while connecting to the database: " . $e->getMessage ();
}
Thanks in advance