Bonjour,
Je suis débutante en PHP/mysql.
J'ai regardé les messages du forum et doc mysql mais la requête suivant ne fait pas ce que je veux.
Où me suis-je trompée ?
En fait j'ai un fichier plat qui contient deux champs (entourés de quillemets et séparés par virgule) date au format français (ex : "14/04/08","25/04/08").
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 $reponse = mysql_query('LOAD DATA INFILE \'price.txt\' INTO TABLE src_ingram_price FIELDS TERMINATED BY \',\' ENCLOSED BY \'\"\' LINES TERMINATED BY \'\\n\' (Date_debut_promotion,Date_fin_promotion) SET Date_debut_promotion=DATE_FORMAT(STR_TO_DATE(Date_debut_promotion,GET_FORMAT(DATE,\'EUR\')),GET_FORMAT(DATE,\'ISO\'));') or die("Impossible de remplir la table : " . mysql_error());
Quand j'execute mon code load data infile, au lieu d'avoir
Date_debut_promotion = 2008/04/14
Date_fin_promotion=2008/04/25
j'ai Date_debut_promotion = 0000-00-00
Date_fin_promotion=2025-04-08
Au début j'avais mis ISO partout pour le format de date, mais ça ne marche pas non plus :
Merci de me dire ce qui ne va pas dans mon code ? Car je suis à court d'idée !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 $reponse = mysql_query('LOAD DATA INFILE \'price.txt\' INTO TABLE src_ingram_price FIELDS TERMINATED BY \',\' ENCLOSED BY \'\"\' LINES TERMINATED BY \'\\n\' (Date_debut_promotion,Date_fin_promotion) SET Date_debut_promotion=DATE_FORMAT(STR_TO_DATE(Date_debut_promotion,GET_FORMAT(DATE,\'ISO\')),GET_FORMAT(DATE,\'ISO\'));') or die("Impossible de remplir la table : " . mysql_error());
Boubou
Partager