1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <?php
$link = mysqli_connect("localhost","id","mdp","bdd"); //On effectue la connexion a la BDD: serveur,id,mdp,nom de la bdd
if(!$link){
die("Erreur de connexion à MySQL");
}
$pathnew="D:/Uwamp/UwAmp/www/test/ResultImport/path_TO_FINAL.txt";
$pathtest="D:/Uwamp/UwAmp/www/test/ResultImport/path_to_TMP.txt";
if( file_exists ($pathtest)){ //Verification de l'existance du fichier
unlink($pathtest) ; //Si il existe, il est supprimer
}
if(mysqli_query($link,'SELECT * INTO OUTFILE "'.$pathtest.'" FIELDS TERMINATED BY \';\' LINES TERMINATED BY \',\' FROM table')){
if(!file_put_contents(''.$pathnew.'', file_get_contents(''.$pathtest.''), FILE_APPEND | LOCK_EX)){
echo("Erreur");
}
}
//Problématique personelle
date_default_timezone_set('Europe/Paris');
$file = fopen("$pathnew", "a");
fwrite($file,date('D,d,M,Y--G\h,i\m,s\s'));
fwrite($file,PHP_EOL);
fclose($file);
?> |
Partager