1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
if (!@copy($source, $destination)) {echo("Erreur: le fichier n'existe pas.");}
if (file_exists($out)) {unlink($out);}
//Correction des caractères du fichier
if (($handle = fopen($in, "r")) !== FALSE)
{
$flag = true;
while(($content = fgets($handle, 4096))!== FALSE)
{
if ($flag) {$flag = false; continue;}
$content = strtohex($content);
$content = strfixchar($content);
$content = hextostr($content);
$content = preg_replace("/([a-zA-Z])('')/", "$1'", $content);
$content = preg_replace("/([0-9])('')/", "$1\"", $content);
file_put_contents($out, $content, FILE_APPEND | LOCK_EX);
}
fclose($handle);
}
mysql_query("
LOAD DATA LOCAL INFILE '".$out."'
INTO TABLE ps_import
FIELDS
TERMINATED BY ';'
ESCAPED BY ''
LINES
TERMINATED BY '\r\n'
IGNORE 1 LINES
(categorie_1, categorie_2, categorie_3, reference,
fabricant, libelle, description, prix, frais_livraison,
prix_ht, url_image, disponibilite, poids, poids_volume,
ecotaxe, ean)
");
$a = "SELECT id_cat_1, categorie_1 FROM ps_import GROUP BY id_cat_1";
$sql_category = mysql_query($a); |
Partager