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
15 require_once './libraries/Table.class.php';
20 require_once './libraries/common.inc.php';
23 PMA_checkParameters(array('db', 'table'));
26 * Defining global variables, in case this script is included by a function.
27 * This is necessary because this script can be included by libraries/header.inc.php.
29 global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
30 $table_info_num_rows, $auto_increment;
33 * Gets table informations
35 // Seems we need to do this in MySQL 5.0.2,
36 // otherwise error #1046, no database selected
37 PMA_DBI_select_db($GLOBALS['db']);
39 $showtable = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table']);
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
46 if (PMA_Table
::isView($GLOBALS['db'], $GLOBALS['table'])) {
48 $tbl_type = $GLOBALS['strView'];
52 $tbl_type = isset($showtable['Engine'])
53 ?
strtoupper($showtable['Engine'])
55 // a new comment could be coming from tbl_operations.php
56 // and we want to show it in the header
57 if (isset($submitcomment) && isset($comment)) {
58 $show_comment = $comment;
60 $show_comment = isset($showtable['Comment'])
61 ?
$showtable['Comment']
65 $tbl_collation = empty($showtable['Collation'])
67 : $showtable['Collation'];
69 if (null === $showtable['Rows']) {
70 $showtable['Rows'] = PMA_Table
::countRecords($GLOBALS['db'],
71 $showtable['Name'], true, true);
73 $table_info_num_rows = isset($showtable['Rows']) ?
$showtable['Rows'] : 0;
74 $row_format = isset($showtable['Row_format']) ?
$showtable['Row_format'] : '';
75 $auto_increment = isset($showtable['Auto_increment'])
76 ?
$showtable['Auto_increment']
79 $create_options = isset($showtable['Create_options'])
80 ?
explode(' ', $showtable['Create_options'])
83 // export create options by its name as variables into global namespace
84 // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
86 foreach ($create_options as $each_create_option) {
87 $each_create_option = explode('=', $each_create_option);
88 if (isset($each_create_option[1])) {
89 $
$each_create_option[0] = $each_create_option[1];
92 // we need explicit DEFAULT value here (different from '0')
93 $pack_keys = (!isset($pack_keys) ||
strlen($pack_keys) == 0) ?
'DEFAULT' : $pack_keys;
94 unset($create_options, $each_create_option);