home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / db_details_db_info.php < prev    next >
Encoding:
PHP Script  |  2004-06-06  |  3.0 KB  |  80 lines

  1. <?php
  2. /* $Id: db_details_db_info.php,v 2.2.4.1 2004/06/07 10:09:52 rabus Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. // Check parameters
  7.  
  8. require_once('./libraries/common.lib.php');
  9.  
  10. PMA_checkParameters(array('db'));
  11.  
  12.  
  13. /**
  14.  * Gets the list of the table in the current db and informations about these
  15.  * tables if possible
  16.  */
  17. // staybyte: speedup view on locked tables - 11 June 2001
  18. $tables = array();
  19. // Special speedup for newer MySQL Versions (in 4.0 format changed)
  20. if ($cfg['SkipLockedTables'] == TRUE) {
  21.     $local_query    = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
  22.     $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  23.     // Blending out tables in use
  24.     if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) {
  25.         while ($tmp = PMA_mysql_fetch_row($db_info_result)) {
  26.             // if in use memorize tablename
  27.             if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
  28.                 $sot_cache[$tmp[0]] = TRUE;
  29.             }
  30.         }
  31.         mysql_free_result($db_info_result);
  32.  
  33.         if (isset($sot_cache)) {
  34.             $local_query    = 'SHOW TABLES FROM ' . PMA_backquote($db);
  35.             $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  36.             if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) {
  37.                 while ($tmp = PMA_mysql_fetch_row($db_info_result)) {
  38.                     if (!isset($sot_cache[$tmp[0]])) {
  39.                         $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
  40.                         $sts_result  = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  41.                         $sts_tmp     = PMA_mysql_fetch_array($sts_result);
  42.  
  43.                         if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
  44.                             $sts_tmp['Type'] =& $sts_tmp['Engine'];
  45.                         }
  46.  
  47.                         $tables[]    = $sts_tmp;
  48.                     } else { // table in use
  49.                         $tables[]    = array('Name' => $tmp[0]);
  50.                     }
  51.                 }
  52.                 mysql_free_result($db_info_result);
  53.                 $sot_ready = TRUE;
  54.             }
  55.         }
  56.     }
  57. }
  58. if (!isset($sot_ready)) {
  59.     $local_query    = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
  60.     $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  61.     if ($db_info_result != FALSE && mysql_num_rows($db_info_result) > 0) {
  62.         while ($sts_tmp = PMA_mysql_fetch_array($db_info_result)) {
  63.             if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
  64.                 $sts_tmp['Type'] =& $sts_tmp['Engine'];
  65.             }
  66.             $tables[] = $sts_tmp;
  67.         }
  68.         mysql_free_result($db_info_result);
  69.     }
  70. }
  71. $num_tables = (isset($tables) ? count($tables) : 0);
  72.  
  73. /**
  74.  * Displays top menu links
  75.  */
  76. echo '<!-- Top menu links -->' . "\n";
  77. require('./db_details_links.php');
  78.  
  79. ?>
  80.