bug #3305606 [interface] Show all button wraps on privileges page
[phpmyadmin/crack.git] / libraries / tbl_info.inc.php
blob00c990413fca5be55677b5c6950e8dfa0c64e552
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
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
9 * @package phpMyAdmin
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
16 * requirements
18 require_once './libraries/common.inc.php';
20 // Check parameters
21 PMA_checkParameters(array('db', 'table'));
23 /**
24 * Defining global variables, in case this script is included by a function.
25 * This is necessary because this script can be included by libraries/header.inc.php.
27 global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
28 $table_info_num_rows, $auto_increment;
30 /**
31 * Gets table informations
33 // Seems we need to do this in MySQL 5.0.2,
34 // otherwise error #1046, no database selected
35 PMA_DBI_select_db($GLOBALS['db']);
38 /**
39 * Holds information about the current table
41 * @todo replace this by PMA_Table
42 * @global array $GLOBALS['showtable']
43 * @name $showtable
45 $GLOBALS['showtable'] = array();
47 // PMA_Table::sGetStatusInfo() does caching by default, but here
48 // we force reading of the current table status
49 // if $reread_info is true (for example, coming from tbl_operations.php
50 // and we just changed the table's storage engine)
51 $GLOBALS['showtable'] = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, (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_type coming from the form
57 if ($showtable) {
58 if (PMA_Table::isView($GLOBALS['db'], $GLOBALS['table'])) {
59 $tbl_is_view = true;
60 $tbl_type = __('View');
61 $show_comment = null;
62 } else {
63 $tbl_is_view = false;
64 $tbl_type = isset($showtable['Engine'])
65 ? strtoupper($showtable['Engine'])
66 : '';
67 // a new comment could be coming from tbl_operations.php
68 // and we want to show it in the header
69 if (isset($submitcomment) && isset($comment)) {
70 $show_comment = $comment;
71 } else {
72 $show_comment = isset($showtable['Comment'])
73 ? $showtable['Comment']
74 : '';
77 $tbl_collation = empty($showtable['Collation'])
78 ? ''
79 : $showtable['Collation'];
81 if (null === $showtable['Rows']) {
82 $showtable['Rows'] = PMA_Table::countRecords($GLOBALS['db'],
83 $showtable['Name'], true);
85 $table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0;
86 $row_format = isset($showtable['Row_format']) ? $showtable['Row_format'] : '';
87 $auto_increment = isset($showtable['Auto_increment'])
88 ? $showtable['Auto_increment']
89 : '';
91 $create_options = isset($showtable['Create_options'])
92 ? explode(' ', $showtable['Create_options'])
93 : array();
95 // export create options by its name as variables into global namespace
96 // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
97 unset($pack_keys);
98 foreach ($create_options as $each_create_option) {
99 $each_create_option = explode('=', $each_create_option);
100 if (isset($each_create_option[1])) {
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) || strlen($pack_keys) == 0) ? 'DEFAULT' : $pack_keys;
106 unset($create_options, $each_create_option);
107 } // end if