home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 August / PCWorld_2001-08_cd.bin / Komunikace / phptriad / phptriadsetup2-11.exe / htdocs / phpMyAdmin / tbl_properties.php < prev    next >
PHP Script  |  2000-08-20  |  9KB  |  245 lines

  1. <?php
  2. /* $Id: tbl_properties.php,v 1.30 2000/07/14 08:44:43 tobias Exp $ */
  3.  
  4. if(!isset($message))
  5. {
  6.     include("header.inc.php");
  7. }
  8. else
  9.     show_message($message);
  10.  
  11. unset($sql_query);
  12. if(MYSQL_MAJOR_VERSION == "3.23")
  13.     {
  14.     if(isset($submitcomment))
  15.         $result = mysql_db_query($db, "ALTER TABLE $table comment='$comment'") or mysql_die();
  16.     $result = mysql_db_query($db, "SHOW TABLE STATUS LIKE '$table'") or mysql_die();
  17.     $row = mysql_fetch_array($result);
  18.     if(!empty($row["Comment"]))
  19.     {
  20.         ?>
  21.         <form method='post' action='tbl_properties.php'>
  22.         <input type="hidden" name="server" value="<?php echo $server;?>">
  23.         <input type="hidden" name="db" value="<?php echo $db;?>">
  24.         <input type="hidden" name="table" value="<?php echo $table;?>">
  25.         <?php
  26.         echo "$strTableComments: <input type='text' name='comment' value='$row[Comment]'><input type='submit' name='submitcomment' value='$strGo'></form>";
  27.     }
  28. }
  29.  
  30. $result = mysql_db_query($db, "SHOW KEYS FROM $table") or mysql_die();
  31. $primary = "";
  32.  
  33. while($row = mysql_fetch_array($result))
  34.     if ($row["Key_name"] == "PRIMARY")
  35.         $primary .= "$row[Column_name], ";
  36.  
  37. $result = mysql_db_query($db, "SHOW FIELDS FROM $table") or mysql_die();
  38.  
  39. ?>
  40. <table border=<?php echo $cfgBorder;?>>
  41. <TR>
  42.    <TH><?php echo $strField; ?></TH>
  43.    <TH><?php echo $strType; ?></TH>
  44.    <TH><?php echo $strAttr; ?></TH>
  45.    <TH><?php echo $strNull; ?></TH>
  46.    <TH><?php echo $strDefault; ?></TH>
  47.    <TH><?php echo $strExtra; ?></TH>
  48.    <?php if (!(isset($printer_friendly) && $printer_friendly)) { ?>
  49.    <TH COLSPAN=5><?php echo $strAction; ?></TH>
  50.    <?php } ?>
  51. </TR>
  52.  
  53. <?php
  54. $i=0;
  55.  
  56. $aryFields = array();
  57.  
  58. while($row= mysql_fetch_array($result))
  59. {
  60.     $aryFields[] = $row["Field"];
  61.     $query = "server=$server&db=$db&table=$table&goto=tbl_properties.php";
  62.     $bgcolor = $cfgBgcolorOne;
  63.     $i % 2  ? 0: $bgcolor = $cfgBgcolorTwo;
  64.     $i++;
  65.     ?>
  66.          <tr bgcolor="<?php echo $bgcolor;?>">
  67.          <td><?php echo $row["Field"];?> </td>
  68.          <td>
  69.     <?php
  70.     $Type = stripslashes($row["Type"]);
  71.     $Type = eregi_replace("BINARY", "", $Type);
  72.     $Type = eregi_replace("ZEROFILL", "", $Type);
  73.     $Type = eregi_replace("UNSIGNED", "", $Type);
  74.     echo $Type;
  75.     ?> </td>
  76.          <td>
  77.     <?php
  78.     $binary   = eregi("BINARY", $row["Type"], $test);
  79.     $unsigned = eregi("UNSIGNED", $row["Type"], $test);
  80.     $zerofill = eregi("ZEROFILL", $row["Type"], $test);
  81.     $strAttribute="";
  82.     if ($binary)
  83.         $strAttribute="BINARY";
  84.     if ($unsigned)
  85.         $strAttribute="UNSIGNED";
  86.     if ($zerofill)
  87.         $strAttribute="UNSIGNED ZEROFILL";
  88.     echo $strAttribute;
  89.     $strAttribute="";
  90.     ?>
  91.       </td>
  92.      <td><?php if ($row["Null"] == "") { echo $strNo;} else {echo $strYes;}?> </td>
  93.          <td><?php if(isset($row["Default"])) echo $row["Default"];?> </td>
  94.          <td><?php echo $row["Extra"];?> </td>
  95.  
  96.      <?php if (!(isset($printer_friendly) && $printer_friendly)) { ?>
  97.          <td><a href="tbl_alter.php?<?php echo $query;?>&field=<?php echo $row["Field"];?>"><?php echo $strChange; ?></a></td>
  98.          <td><a href="sql.php?<?php echo $query;?>&sql_query=<?php echo urlencode("ALTER TABLE ".$table." DROP ".$row["Field"]);?>&zero_rows=<?php echo urlencode($row["Field"]." ".$strHasBeenDropped);?>"><?php echo $strDrop; ?></a></td>
  99.          <td><a href="sql.php?<?php echo $query;?>&sql_query=<?php echo urlencode("ALTER TABLE ".$table." DROP PRIMARY KEY, ADD PRIMARY KEY($primary".$row["Field"].")");?>&zero_rows=<?php echo urlencode($strAPrimaryKey.$row["Field"]);?>"><?php echo $strPrimary; ?></a></td>
  100.          <td><a href="sql.php?<?php echo $query;?>&sql_query=<?php echo urlencode("ALTER TABLE ".$table." ADD INDEX(".$row["Field"].")");?>&zero_rows=<?php echo urlencode($strAnIndex.$row["Field"]);?>"><?php echo $strIndex; ?></a></td>
  101.          <td><a href="sql.php?<?php echo $query;?>&sql_query=<?php echo urlencode("ALTER TABLE ".$table." ADD UNIQUE(".$row["Field"].")");?>&zero_rows=<?php echo urlencode($strAnIndex.$row["Field"]);?>"><?php echo $strUnique; ?></a></td>
  102.      <?php } ?>
  103.          </tr>
  104.     <?php
  105. }
  106. ?>
  107. </table>
  108. <?php
  109.  
  110. $result = mysql_db_query($db, "SHOW KEYS FROM ".$table) or mysql_die();
  111. if(mysql_num_rows($result)>0)
  112. {
  113.     ?>
  114.     <br>
  115.     <table border=<?php echo $cfgBorder;?>>
  116.       <tr>
  117.       <th><?php echo $strKeyname; ?></th>
  118.       <th><?php echo $strUnique; ?></th>
  119.       <th><?php echo $strField; ?></th>
  120.       <th><?php echo $strAction; ?></th>
  121.       </tr>
  122.     <?php
  123.     for($i=0 ; $i<mysql_num_rows($result); $i++)
  124.     {
  125.         $row = mysql_fetch_array($result);
  126.         echo "<tr>";
  127.         if($row["Key_name"] == "PRIMARY")
  128.         {
  129.             $sql_query = urlencode("ALTER TABLE ".$table." DROP PRIMARY KEY");
  130.             $zero_rows = urlencode($strPrimaryKey." ".$strHasBeenDropped);
  131.         }
  132.         else
  133.         {
  134.             $sql_query = urlencode("ALTER TABLE ".$table." DROP INDEX ".$row["Key_name"]);
  135.             $zero_rows = urlencode($strIndex." ".$row["Key_name"]." ".$strHasBeenDropped);
  136.         }
  137.  
  138.         ?>
  139.           <td><?php echo $row["Key_name"];?></td>
  140.           <td><?php
  141.         if($row["Non_unique"]=="0")
  142.             echo $strYes;
  143.         else
  144.             echo $strNo;
  145.         ?></td>
  146.         <td><?php echo $row["Column_name"];?></td>
  147.         <td><?php echo "<a href=\"sql.php?$query&sql_query=$sql_query&zero_rows=$zero_rows\">$strDrop</a>";?></td>
  148.         <?php
  149.         echo "</tr>";
  150.     }
  151.     print "</table>\n";
  152.     print show_docu("manual_Performance.html#MySQL_indexes");
  153. }
  154.  
  155. ?>
  156. <div align="left">
  157. <ul>
  158. <li><a href="tbl_printview.php?<?php echo $query;?>"><?php echo $strPrintView; ?></a>
  159. <li><a href="sql.php?sql_query=<?php echo urlencode("SELECT * FROM $table");?>&pos=0&<?php echo $query;?>"><?php echo $strBrowse; ?></a>
  160. <li><a href="tbl_select.php?<?php echo $query;?>"><?php echo $strSelect; ?></a>
  161. <li><a href="tbl_change.php?<?php echo $query;?>"><?php echo $strInsert; ?></a>
  162. <li><form method="post" action="tbl_addfield.php"> <input type="hidden" name="server" value="<?php echo $server;?>">
  163.  <input type="hidden" name="db" value="<?php echo $db;?>">
  164.  <input type="hidden" name="table" value="<?php echo $table;?>">
  165. <?php echo " ".$strAddNewField; ?>:  <input name="num_fields" size=2 maxlength=2 value=1>
  166. <?php
  167. echo " ";
  168. echo " <select name=\"after_field\">\n";
  169. echo '  <option value="--end--">'.$strAtEndOfTable."</option>\n";
  170. echo '  <option value="--first--">'.$strAtBeginningOfTable."</option>\n";
  171. while(list ($junk,$fieldname) = each($aryFields)) {
  172.     echo '  <option value="'.$fieldname.'">'.$strAfter.' '.$fieldname."</option>\n";
  173. }
  174. echo " </select>\n";
  175. ?>
  176. <input type="submit" value="<?php echo $strGo;?>">
  177. </form>
  178. <li><a href="ldi_table.php?<?php echo $query;?>"><?php echo $strInsertTextfiles; ?></a>
  179. <li><form method="post" action="tbl_dump.php"><?php echo $strViewDump;?><br>
  180. <table>
  181.     <tr>
  182.         <td>
  183.             <input type="radio" name="what" value="structure" checked><?php echo $strStrucOnly;?>
  184.         </td>
  185.         <td>
  186.             <input type="checkbox" name="drop" value="1"><?php echo $strStrucDrop;?>
  187.         </td>
  188.         <td colspan="3">
  189.             <input type="submit" value="<?php echo $strGo;?>">
  190.         </td>
  191.     </tr>
  192.     <tr>
  193.         <td>
  194.             <input type="radio" name="what" value="data"><?php echo $strStrucData;?>
  195.         </td>
  196.         <td>
  197.             <input type="checkbox" name="asfile" value="sendit"><?php echo $strSend;?>
  198.         </td>
  199.     </tr>
  200.     <tr>
  201.     <td>
  202.     </td>
  203.     <td>
  204.        <input type="checkbox" name="showcolumns" value="yes"><?php echo $strCompleteInserts; ?>
  205.     </td>
  206.     </tr>
  207.     <tr>
  208.         <td>
  209.             <input type="radio" name="what" value="csv"><?php echo $strStrucCSV;?>
  210.         </td>
  211.         <td>
  212.             <?php echo $strTerminatedBy;?> <input type="text" name="separator" size=1 value=";">
  213.         </td>
  214.     </tr>
  215. </table>
  216.  
  217.  <input type="hidden" name="server" value="<?php echo $server;?>">
  218.  <input type="hidden" name="db" value="<?php echo $db;?>">
  219.  <input type="hidden" name="table" value="<?php echo $table;?>">
  220. </form>
  221.  
  222. <li><form method="post" action="tbl_rename.php"><?php echo $strRenameTable;?>:<br>
  223.  <input type="hidden" name="server" value="<?php echo $server;?>">
  224.  <input type="hidden" name="db" value="<?php echo $db;?>">
  225.  <input type="hidden" name="table" value="<?php echo $table;?>">
  226.  <input type="hidden" name="reload" value="true">
  227.  <input type="text" name="new_name"><input type="submit" value="<?php echo $strGo;?>">
  228. </form>
  229. <li><form method="post" action="tbl_copy.php"><?php echo $strCopyTable;?><br>
  230.  <input type="hidden" name="server" value="<?php echo $server;?>">
  231.  <input type="hidden" name="db" value="<?php echo $db;?>">
  232.  <input type="hidden" name="table" value="<?php echo $table;?>">
  233.  <input type="hidden" name="reload" value="true">
  234.  <input type="text" name="new_name"><br>
  235.  <input type="radio" name="what" value="structure" checked><?php echo $strStrucOnly;?>
  236.  <input type="radio" name="what" value="data"><?php echo $strStrucData;?>
  237.  <input type="submit" value="<?php echo $strGo;?>">
  238. </form>
  239.  
  240. </ul>
  241. </div>
  242. <?
  243.  
  244. require ("footer.inc.php");
  245. ?>