home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / tbl_info.inc.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  3.5 KB  |  112 lines

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