Mysql et php

Bonjour,
j'ai la structure d'une base de donnée dans un fichier mysql.
maitenant j'aimerais aller modifier la structure d'une autre base
de donnée à l'aide de ce fichier en php.
c'est à dire que le script vérifiera les tables et les champs manquants
afin de les ajouter dans la base de donnée
Configuration: Windows Vista
Opera 9.62

3 réponses

  1. salut
    y a pas de question!
    1. ok!
      j'ai bidouiller un script mais qui ne marche pas correctement:
      en fait ici, je veus 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 <br>"; echo $TotalTableDist." Table Distantes<br>";

      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 / <br> ";
      /*$NbredeChampAjoute++;
      $champ=$ChampLoc["Field"];
      $type=$ChampLoc["Type"];
      $Extra=($ChampLoc
      }
      }
      }

      }
      }
    2. @brudao$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 <br>"; echo $TotalTableDist." Table Distantes<br>";

      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 / <br> ";

      }
      }
      }

      }
      }