2 /* vim: set expandtab sw=4 ts=4 sts=4: */
7 if (! defined('PHPMYADMIN')) {
14 require_once './libraries/Table.class.php';
17 * extracts table properties from create statement
19 * @todo this should be recoded as functions,
20 * to avoid messing with global variables
26 require_once './libraries/common.inc.php';
29 PMA_checkParameters(array('db', 'table'));
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.
35 global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
36 $table_info_num_rows, $auto_increment;
39 * Gets table informations
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']);
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
);
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
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);
59 if (!isset($showtable['Type']) && isset($showtable['Engine'])) {
60 $showtable['Type'] =& $showtable['Engine'];
62 if (PMA_Table
::isView($GLOBALS['db'], $GLOBALS['table'])) {
64 $tbl_type = $GLOBALS['strView'];
68 $tbl_type = isset($showtable['Type'])
69 ?
strtoupper($showtable['Type'])
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;
76 $show_comment = isset($showtable['Comment'])
77 ?
$showtable['Comment']
81 $tbl_collation = empty($showtable['Collation'])
83 : $showtable['Collation'];
85 if (null === $showtable['Rows']) {
86 $showtable['Rows'] = PMA_Table
::countRecords($GLOBALS['db'],
87 $showtable['Name'], true, true);
89 $table_info_num_rows = isset($showtable['Rows']) ?
$showtable['Rows'] : 0;
90 $auto_increment = isset($showtable['Auto_increment'])
91 ?
$showtable['Auto_increment']
94 $create_options = isset($showtable['Create_options'])
95 ?
explode(' ', $showtable['Create_options'])
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'
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];
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);