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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
| <?
class ExploseurDeDate {
var $j_immat = '01';
var $m_immat;
var $a_immat;
function ExploseurDeDate($date) {
$mois = array('janv'=>'01','fév'=>'02','mars'=>'03', 'avr' => '04', 'mai' => '05', 'juin' => '06', 'juil' => '07', 'aout' => '08', 'sept' => '09', 'oct' => '10', 'nov' => '11', 'déc' => '12',);
$tab_date = explode('-',$date);
$this->m_immat = $mois[$tab_date[0]];
$this->a_immat = $tab_date[1];
}
function getJour() {
return $this->j_immat;
}
function getMois() {
return $this->m_immat;
}
function getAnnee() {
return $this->a_immat;
}
}
$date = new ExploseurDeDate('fév-2007');
mysql_connect('localhost', 'xxxx', 'xxxxxxxxxxx');
mysql_select_db('xxxxxxxxxxxx');
$fichier='test2.csv';
$fp = fopen("$fichier", "r");
while (!feof($fp))
{
$ligne = fgets($fp,4096);
/* ----------------------------------------- */
$liste = explode( ";",$ligne);
/* ----------------------------------------- */
$make = $liste[0];
$model = $liste[1];
$description = $liste[2];
$exterior = $liste[3];
$model_year= $liste[4];
$mileage= $liste[5];
$frais= $liste[6];
$price= $liste[7];
$userid = "1";
$location = "1";
$user_type = "3";
$added = $datejour;
$updated = $datejour;
$expire = "0";
$user_expire = "0";
$viewed = "64";
$images = "0";
$hide = "0";
$featured = "0";
$status = "1";
$pending = "";
$stock = "";
$vin = "";
$cond = "Occasion";
$gen = "VP";
$carross = "CI";
$category = "";
$category2 = "";
$mileage_alt = "";
$sale = "";
$price_alt = "";
$interior = "";
$doors = "";
$fuel = "GO";
$drive = "";
$engine = "";
$trans = "";
$top_speed = "";
$horsepower = "";
$torque = "";
$towing = "";
$features = "";
$tagline = "";
$link_url = "";
$link_text = "";
$ebay_url = "";
$nom_acheteur = "";
$adresse_acheteur = "";
$cp_acheteur = "";
$ville_acheteur = "";
$w_garage = "";
$j_immat = "";
$m_immat = "";
$a_immat = "";
$query = "INSERT INTO test (userid,location,user_type,added,updated,expire,user_expire,viewed,images,hide,featured,status,pending,stock,vin,model_year,make,model,cond,gen,carross,category,category2,mileage,mileage_alt,price,sale,price_alt,exterior,interior,doors,fuel,drive,engine,trans,top_speed,horsepower,torque,towing,features,description,tagline,link_url,link_text,ebay_url,nom_acheteur,adresse_acheteur,cp_acheteur,ville_acheteur,w_garage,j_immat,m_immat,a_immat,frais)
VALUES('$userid','$location','$user_type','$added','$updated','$expire','$user_expire','$viewed','$images','$hide','$featured','$status','$pending','$stock','$vin','$model_year','$make','$model','$cond','$gen','$carross','$category','$category2','$mileage','$mileage_alt','$price','$sale','$price_alt','$exterior','$interior','$doors','$fuel','$drive','$engine','$trans','$top_speed','$horsepower','$torque','$towing','$features','$description','$tagline','$link_url','$link_text','$ebay_url','$nom_acheteur','$adresse_acheteur','$cp_acheteur','$ville_acheteur','$w_garage','$j_immat','$m_immat','$a_immat','$frais')";
$result= MYSQL_QUERY($query);
if(mysql_error())
{
print "Erreur !!!!!!!!!!".mysql_error();
print "<br>Importation arrete.";
exit();
}
else /* Tout va bien */
print "$make $model $description $exterior $model_year $mileage $frais $price $j_immat $m_immat $a_immat<br>";
}
echo "$query";
/* Fermeture */
fclose($fp);
MYSQL_CLOSE()
?> |
Partager