[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/libraries/ -> db_info.inc.php (source)

   1  <?php
   2  /* $Id: db_info.inc.php 9602 2006-10-25 12:25:01Z nijel $ */
   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  $is_show_stats = $cfg['ShowStats'];
  13  
  14  if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) {
  15      $is_show_stats = false;
  16      $db_is_information_schema = true;
  17  } else {
  18      $db_is_information_schema = false;
  19  }
  20  
  21  function fillTooltip( &$tooltip_truename, &$tooltip_aliasname, &$tmp ) {
  22      $tooltip_truename[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']);
  23      $tooltip_aliasname[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested'  ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']));
  24      if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) {
  25          $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Create_time']));
  26      }
  27  
  28      if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) {
  29          $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Update_time']));
  30      }
  31  
  32      if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) {
  33          $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Check_time']));
  34      }
  35  
  36      return true;
  37  }
  38  
  39  /**
  40   * Gets the list of the table in the current db and informations about these
  41   * tables if possible
  42   */
  43  // staybyte: speedup view on locked tables - 11 June 2001
  44  $tables = array();
  45  
  46  // When used in Nested table group mode, only show tables matching the given groupname
  47  if (!empty($tbl_group) && !$cfg['ShowTooltipAliasTB']) {
  48      $tbl_group_sql = ' LIKE "' . PMA_escape_mysql_wildcards( $tbl_group ) . '%"';
  49  } else {
  50      $tbl_group_sql = '';
  51  }
  52  
  53  if ( $cfg['ShowTooltip'] ) {
  54      $tooltip_truename = array();
  55      $tooltip_aliasname = array();
  56  }
  57  
  58  // Special speedup for newer MySQL Versions (in 4.0 format changed)
  59  if ( true === $cfg['SkipLockedTables'] ) {
  60      $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
  61      
  62      // Blending out tables in use
  63      if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
  64          while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
  65              // if in use memorize tablename
  66              if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
  67                  $sot_cache[$tmp[0]] = TRUE;
  68              }
  69          }
  70          PMA_DBI_free_result($db_info_result);
  71  
  72          if (isset($sot_cache)) {
  73              $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', null, PMA_DBI_QUERY_STORE);
  74              if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
  75                  while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
  76                      if (!isset($sot_cache[$tmp[0]])) {
  77                          $sts_result  = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
  78                          $sts_tmp     = PMA_DBI_fetch_assoc($sts_result);
  79                          PMA_DBI_free_result($sts_result);
  80                          unset($sts_result);
  81  
  82                          if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
  83                              $sts_tmp['Type'] =& $sts_tmp['Engine'];
  84                          }
  85  
  86                          if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) {
  87                              continue;
  88                          }
  89  
  90                          if ($cfg['ShowTooltip']) {
  91                              fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
  92                          }
  93  
  94                          $tables[$sts_tmp['Name']]    = $sts_tmp;
  95                      } else { // table in use
  96                          $tables[$tmp[0]]    = array('Name' => $tmp[0]);
  97                      }
  98                  }
  99                  PMA_DBI_free_result($db_info_result);
 100                  
 101                  if ( $GLOBALS['cfg']['NaturalOrder'] ) {
 102                      uksort( $tables, 'strnatcasecmp' );
 103                  }
 104  
 105                  $sot_ready = TRUE;
 106              }
 107          }
 108      } else {
 109          PMA_DBI_free_result($db_info_result);
 110          unset($db_info_result);
 111      }
 112  }
 113  
 114  if ( ! isset( $sot_ready ) ) {
 115      if ( ! empty( $tbl_group ) && ! $cfg['ShowTooltipAliasTB'] ) {
 116          // only tables for selected group
 117          $tables = PMA_DBI_get_tables_full( $db, $tbl_group, true );
 118      } elseif ( ! empty( $tbl_group ) && $cfg['ShowTooltipAliasTB'] ) {
 119          // only tables for selected group,
 120          // but grouping is done on comment ...
 121          $tables = PMA_DBI_get_tables_full( $db, $tbl_group, 'comment' );
 122      } else {
 123          // all tables in db
 124          $tables = PMA_DBI_get_tables_full( $db );
 125      }
 126      
 127      if ( $cfg['ShowTooltip'] ) {
 128          foreach ( $tables as $each_table ) {
 129              fillTooltip( $tooltip_truename, $tooltip_aliasname, $each_table );
 130          }
 131      }
 132  }
 133  
 134  $num_tables = count( $tables );
 135  
 136  /**
 137   * Displays top menu links
 138   */
 139  require ('./libraries/db_links.inc.php');
 140  ?>


Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics