[ 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/ -> tbl_info.inc.php (source)

   1  <?php
   2  /* $Id: tbl_info.inc.php 9601 2006-10-25 10:55:20Z nijel $ */
   3  // vim: expandtab sw=4 ts=4 sts=4:
   4  
   5  require_once  './libraries/Table.class.php';
   6  
   7  /**
   8   * extracts table properties from create statement
   9   *
  10   * @todo this should be recoded as functions,
  11   * to avoid messing with global variables
  12   */
  13  
  14  /**
  15   * requirements
  16   */
  17  require_once ('./libraries/common.lib.php');
  18  
  19  // Check parameters
  20  PMA_checkParameters(array('db', 'table'));
  21  
  22  /**
  23   * Defining global variables, in case this script is included by a function.
  24   * This is necessary because this script can be included by libraries/header.inc.php.
  25   */
  26  global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
  27         $table_info_num_rows, $auto_increment;
  28  
  29  /**
  30   * Gets table informations
  31   */
  32  // Seems we need to do this in MySQL 5.0.2,
  33  // otherwise error #1046, no database selected
  34  PMA_DBI_select_db($GLOBALS['db']);
  35  
  36  // The 'show table' statement works correct since 3.23.03
  37  $table_info_result   = PMA_DBI_query(
  38      'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\';',
  39      null, PMA_DBI_QUERY_STORE);
  40  
  41  // need this test because when we are creating a table, we get 0 rows
  42  // from the SHOW TABLE query
  43  // and we don't want to mess up the $tbl_type coming from the form
  44  
  45  if ($table_info_result && PMA_DBI_num_rows($table_info_result) > 0) {
  46      $showtable           = PMA_DBI_fetch_assoc($table_info_result);
  47      PMA_DBI_free_result($table_info_result);
  48      unset( $table_info_result );
  49  
  50      if (!isset($showtable['Type']) && isset($showtable['Engine'])) {
  51          $showtable['Type'] =& $showtable['Engine'];
  52      }
  53      // MySQL < 5.0.13 returns "view", >= 5.0.13 returns "VIEW"
  54      if ( PMA_MYSQL_INT_VERSION >= 50000 && !isset($showtable['Type'])
  55        && isset($showtable['Comment'])
  56        && strtoupper($showtable['Comment']) == 'VIEW' ) {
  57          $tbl_is_view     = true;
  58          $tbl_type        = $GLOBALS['strView'];
  59          $show_comment    = null;
  60      } else {
  61          $tbl_is_view     = false;
  62          $tbl_type        = isset($showtable['Type'])
  63              ? strtoupper($showtable['Type'])
  64              : '';
  65          // a new comment could be coming from tbl_operations.php
  66          // and we want to show it in the header
  67          if (isset($submitcomment) && isset($comment)) {
  68              $show_comment = $comment;
  69          } else {
  70              $show_comment    = isset($showtable['Comment'])
  71                  ? $showtable['Comment']
  72                  : '';
  73          }
  74      }
  75      $tbl_collation       = empty($showtable['Collation'])
  76          ? ''
  77          : $showtable['Collation'];
  78  
  79      if ( null === $showtable['Rows'] ) {
  80          $showtable['Rows']   = PMA_Table::countRecords( $GLOBALS['db'],
  81              $showtable['Name'], true, true );
  82      }
  83      $table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0;
  84      $auto_increment      = isset($showtable['Auto_increment'])
  85          ? $showtable['Auto_increment']
  86          : '';
  87  
  88      $create_options      = isset($showtable['Create_options'])
  89          ? explode(' ', $showtable['Create_options'])
  90          : array();
  91  
  92      // export create options by its name as variables into gloabel namespace
  93      // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
  94      unset($pack_keys);
  95      foreach ( $create_options as $each_create_option ) {
  96          $each_create_option = explode('=', $each_create_option);
  97          if ( isset( $each_create_option[1] ) ) {
  98              $$each_create_option[0]    = $each_create_option[1];
  99          }
 100      }
 101      // we need explicit DEFAULT value here (different from '0')
 102      $pack_keys = (!isset($pack_keys) || strlen($pack_keys) == 0) ? 'DEFAULT' : $pack_keys;
 103      unset( $create_options, $each_create_option );
 104  } // end if
 105  ?>


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