2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * extracts table properties from create statement
6 * @todo should be handled by class Table
7 * @todo this should be recoded as functions, to avoid messing with global variables
12 if (! defined('PHPMYADMIN')) {
19 require_once './libraries/Table.class.php';
24 require_once './libraries/common.inc.php';
27 PMA_checkParameters(array('db', 'table'));
30 * Defining global variables, in case this script is included by a function.
31 * This is necessary because this script can be included by libraries/header.inc.php.
33 global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
34 $table_info_num_rows, $auto_increment;
37 * Gets table informations
39 // Seems we need to do this in MySQL 5.0.2,
40 // otherwise error #1046, no database selected
41 PMA_DBI_select_db($GLOBALS['db']);
45 * Holds information about the current table
47 * @todo replace this by PMA_Table
48 * @global array $GLOBALS['showtable']
51 $GLOBALS['showtable'] = array();
53 // PMA_Table::sGetStatusInfo() does caching by default, but here
54 // we force reading of the current table status
55 // if $reread_info is true (for example, coming from tbl_operations.php
56 // and we just changed the table's storage engine)
57 $GLOBALS['showtable'] = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, (isset($reread_info) && $reread_info ?
true : false));
59 // need this test because when we are creating a table, we get 0 rows
60 // from the SHOW TABLE query
61 // and we don't want to mess up the $tbl_type coming from the form
64 if (PMA_Table
::isView($GLOBALS['db'], $GLOBALS['table'])) {
66 $tbl_type = $GLOBALS['strView'];
70 $tbl_type = isset($showtable['Engine'])
71 ?
strtoupper($showtable['Engine'])
73 // a new comment could be coming from tbl_operations.php
74 // and we want to show it in the header
75 if (isset($submitcomment) && isset($comment)) {
76 $show_comment = $comment;
78 $show_comment = isset($showtable['Comment'])
79 ?
$showtable['Comment']
83 $tbl_collation = empty($showtable['Collation'])
85 : $showtable['Collation'];
87 if (null === $showtable['Rows']) {
88 $showtable['Rows'] = PMA_Table
::countRecords($GLOBALS['db'],
89 $showtable['Name'], true);
91 $table_info_num_rows = isset($showtable['Rows']) ?
$showtable['Rows'] : 0;
92 $row_format = isset($showtable['Row_format']) ?
$showtable['Row_format'] : '';
93 $auto_increment = isset($showtable['Auto_increment'])
94 ?
$showtable['Auto_increment']
97 $create_options = isset($showtable['Create_options'])
98 ?
explode(' ', $showtable['Create_options'])
101 // export create options by its name as variables into global namespace
102 // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
104 foreach ($create_options as $each_create_option) {
105 $each_create_option = explode('=', $each_create_option);
106 if (isset($each_create_option[1])) {
107 $
$each_create_option[0] = $each_create_option[1];
110 // we need explicit DEFAULT value here (different from '0')
111 $pack_keys = (!isset($pack_keys) ||
strlen($pack_keys) == 0) ?
'DEFAULT' : $pack_keys;
112 unset($create_options, $each_create_option);