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
11 if (! defined('PHPMYADMIN')) {
16 PMA_Util
::checkParameters(array('db', 'table'));
19 * Defining global variables, in case this script is included by a function.
21 global $showtable, $tbl_is_view, $tbl_storage_engine, $show_comment, $tbl_collation,
22 $table_info_num_rows, $auto_increment;
25 * Gets table information
27 // Seems we need to do this in MySQL 5.0.2,
28 // otherwise error #1046, no database selected
29 $GLOBALS['dbi']->selectDb($GLOBALS['db']);
33 * Holds information about the current table
35 * @todo replace this by PMA_Table
36 * @global array $GLOBALS['showtable']
39 $GLOBALS['showtable'] = array();
41 // PMA_Table::getStatusInfo() does caching by default, but here
42 // we force reading of the current table status
43 // if $reread_info is true (for example, coming from tbl_operations.php
44 // and we just changed the table's storage engine)
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 /** @var PMA_String $pmaString */
59 $pmaString = $GLOBALS['PMA_String'];
61 if ($GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])->isView()) {
63 $tbl_storage_engine = __('View');
67 $tbl_storage_engine = isset($showtable['Engine'])
68 ?
/*overload*/mb_strtoupper($showtable['Engine'])
71 if (isset($showtable['Comment'])) {
72 $show_comment = $showtable['Comment'];
75 $tbl_collation = empty($showtable['Collation'])
77 : $showtable['Collation'];
79 if (null === $showtable['Rows']) {
80 $showtable['Rows'] = $GLOBALS['dbi']
81 ->getTable($GLOBALS['db'], $showtable['Name'])
84 $table_info_num_rows = isset($showtable['Rows']) ?
$showtable['Rows'] : 0;
85 $row_format = isset($showtable['Row_format']) ?
$showtable['Row_format'] : '';
86 $auto_increment = isset($showtable['Auto_increment'])
87 ?
$showtable['Auto_increment']
90 $create_options = isset($showtable['Create_options'])
91 ?
explode(' ', $showtable['Create_options'])
94 // export create options by its name as variables into global namespace
95 // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
97 foreach ($create_options as $each_create_option) {
98 $each_create_option = explode('=', $each_create_option);
99 if (isset($each_create_option[1])) {
100 // ensure there is no ambiguity for PHP 5 and 7
101 $
{$each_create_option[0]} = $each_create_option[1];
104 // we need explicit DEFAULT value here (different from '0')
105 $pack_keys = (! isset($pack_keys) ||
/*overload*/mb_strlen($pack_keys) == 0)
108 unset($create_options, $each_create_option);
110 $pack_keys = $row_format = null;