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 informations
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::sGetStatusInfo() 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'] = PMA_Table
::sGetStatusInfo(
49 (isset($reread_info) && $reread_info ?
true : false)
52 // need this test because when we are creating a table, we get 0 rows
53 // from the SHOW TABLE query
54 // and we don't want to mess up the $tbl_storage_engine coming from the form
57 if (PMA_Table
::isView($GLOBALS['db'], $GLOBALS['table'])) {
59 $tbl_storage_engine = __('View');
63 $tbl_storage_engine = isset($showtable['Engine'])
64 ?
strtoupper($showtable['Engine'])
67 if (isset($showtable['Comment'])) {
68 $show_comment = $showtable['Comment'];
71 $tbl_collation = empty($showtable['Collation'])
73 : $showtable['Collation'];
75 if (null === $showtable['Rows']) {
76 $showtable['Rows'] = PMA_Table
::countRecords(
77 $GLOBALS['db'], $showtable['Name'], true
80 $table_info_num_rows = isset($showtable['Rows']) ?
$showtable['Rows'] : 0;
81 $row_format = isset($showtable['Row_format']) ?
$showtable['Row_format'] : '';
82 $auto_increment = isset($showtable['Auto_increment'])
83 ?
$showtable['Auto_increment']
86 $create_options = isset($showtable['Create_options'])
87 ?
explode(' ', $showtable['Create_options'])
90 // export create options by its name as variables into global namespace
91 // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
93 foreach ($create_options as $each_create_option) {
94 $each_create_option = explode('=', $each_create_option);
95 if (isset($each_create_option[1])) {
96 $
$each_create_option[0] = $each_create_option[1];
99 // we need explicit DEFAULT value here (different from '0')
100 $pack_keys = (! isset($pack_keys) ||
strlen($pack_keys) == 0)
103 unset($create_options, $each_create_option);