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')) {
17 PMA\libraries\Util
::checkParameters(array('db', 'table'));
20 * Defining global variables, in case this script is included by a function.
22 global $showtable, $tbl_is_view, $tbl_storage_engine, $show_comment, $tbl_collation,
23 $table_info_num_rows, $auto_increment;
26 * Gets table information
28 // Seems we need to do this in MySQL 5.0.2,
29 // otherwise error #1046, no database selected
30 $GLOBALS['dbi']->selectDb($GLOBALS['db']);
34 * Holds information about the current table
36 * Table::getStatusInfo() does caching by default, but here
37 * we force reading of the current table status
38 * if $reread_info is true (for example, coming from tbl_operations.php
39 * and we just changed the table's storage engine)
41 * @todo replace this by Table
42 * @global array $GLOBALS['showtable']
45 $GLOBALS['showtable'] = $GLOBALS['dbi']->getTable(
50 (isset($reread_info) && $reread_info ?
true : false)
53 // need this test because when we are creating a table, we get 0 rows
54 // from the SHOW TABLE query
55 // and we don't want to mess up the $tbl_storage_engine coming from the form
58 if ($GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])->isView()) {
60 $tbl_storage_engine = __('View');
64 $tbl_storage_engine = isset($showtable['Engine'])
65 ?
mb_strtoupper($showtable['Engine'])
68 if (isset($showtable['Comment'])) {
69 $show_comment = $showtable['Comment'];
72 $tbl_collation = empty($showtable['Collation'])
74 : $showtable['Collation'];
76 if (null === $showtable['Rows']) {
77 $showtable['Rows'] = $GLOBALS['dbi']
78 ->getTable($GLOBALS['db'], $showtable['Name'])
81 $table_info_num_rows = isset($showtable['Rows']) ?
$showtable['Rows'] : 0;
82 $row_format = isset($showtable['Row_format']) ?
$showtable['Row_format'] : '';
83 $auto_increment = isset($showtable['Auto_increment'])
84 ?
$showtable['Auto_increment']
87 $create_options_tmp = isset($showtable['Create_options'])
88 ?
explode(' ', $showtable['Create_options'])
90 $create_options = array();
92 // export create options by its name as variables into global namespace
93 // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
95 foreach ($create_options_tmp as $each_create_option) {
96 $each_create_option = explode('=', $each_create_option);
97 if (isset($each_create_option[1])) {
98 // ensure there is no ambiguity for PHP 5 and 7
99 $create_options[$each_create_option[0]] = $each_create_option[1];
102 // we need explicit DEFAULT value here (different from '0')
103 $create_options['pack_keys'] = (! isset($create_options['pack_keys']) ||
strlen($create_options['pack_keys']) == 0)
105 : $create_options['pack_keys'];
106 unset($create_options_tmp, $each_create_option);
108 $pack_keys = $row_format = null;