bonjour!
j'ai bidouiller un script mais qui ne marche pas correctement:
je possede 2 bases de données mysql.
je veux lister les champs qui existent dans ma-base1 et qui n'existe pas dans ma-base2
$ServeurDistant='localhost';
$UserDistant='root';
$PassworDistant= ' ';
$BdDistante='ma_base1';
/*****************************/
$ServeurLocal='localhost';
$UserLocal='root';
$PasswordLocal= ' ';
$BdLocale='ma-base2;
/*****************************/
$ConnectDistante = mysql_connect($ServeurDistant,$UserDistant,$PassworDistant);
mysql_select_db($BdDistante,$ConnectDistante);
$ListeTableDistante = mysql_list_tables ($BdDistante);
$TotalTableDist=mysql_num_rows ($ListeTableDistante);
/***********************************************/
$ConnectLocale = mysql_connect($ServeurLocal,$UserLocal,$PasswordLocal);
mysql_select_db($BdLocale,$ConnectLocale);
$ListeTableLocale = mysql_list_tables ($BdLocale);
$TotalTableLoc=mysql_num_rows ($ListeTableLocale);
/************************************************/
//echo $TotalTableLoc." Table Locales
"; echo $TotalTableDist." Table Distantes
";
for($i=0;$i<$TotalTableLoc;$i++)
{
$NomTableLoc[$i] = mysql_tablename ($ListeTableLocale,$i);
for ($j=0;$j<$TotalTableDist;$j++)
{
$NomTableDist[$j] = mysql_tablename ($ListeTableDistante,$j);
if ($NomTableLoc[$i]==$NomTableDist[$j])
{
mysql_select_db($BdLocale, $ConnectLocale);
$DescripTable1 = mysql_query("DESCRIBE $NomTableLoc[$i]",
$ConnectLocale) or die("Erreur 5 lors de la requête : ".mysql_error()."\n");
$TotalTable1=mysql_num_rows ($DescripTable1);
mysql_select_db($BdDistante, $ConnectDistante);
$DescripTable2 = mysql_query("DESCRIBE $NomTableDist[$j]",
$ConnectDistante) or die("Erreur 6 lors de la requête : ".mysql_error()."\n");
$TotalTable2=mysql_num_rows ($DescripTable2);
for($x=0;$x<$TotalTable1;$x++)
{
$ChampLoc= mysql_fetch_array($DescripTable1);
for($y=0;$y<$TotalTable2;$y++)
{
$ChampDist= mysql_fetch_array($DescripTable2);
if ($ChampLoc["Field"]==$ChampDist["Field"])
{
// echo $ChampLoc["Field"]." Existe ";
$y=$TotalTable2+5;
}
}
if ($y==$TotalTable2)
{
echo " / ".$ChampLoc["Field"]." n'existe
pas /
";
/*$NbredeChampAjoute++;
$champ=$ChampLoc["Field"];
$type=$ChampLoc["Type"];
$Extra=($ChampLoc
}
}
}
}
}
Afficher la suite