bug #1763343 [session] Behavior with session.auto_start enabled
[phpmyadmin/sankalp_k.git] / libraries / tbl_info.inc.php
blob9aeb9ceea1bf63cca8c6e51bd5dea05f5d2866fc
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
11 require_once './libraries/Table.class.php';
13 /**
14 * extracts table properties from create statement
16 * @todo this should be recoded as functions,
17 * to avoid messing with global variables
20 /**
21 * requirements
23 require_once './libraries/common.inc.php';
25 // Check parameters
26 PMA_checkParameters(array('db', 'table'));
28 /**
29 * Defining global variables, in case this script is included by a function.
30 * This is necessary because this script can be included by libraries/header.inc.php.
32 global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
33 $table_info_num_rows, $auto_increment;
35 /**
36 * Gets table informations
38 // Seems we need to do this in MySQL 5.0.2,
39 // otherwise error #1046, no database selected
40 PMA_DBI_select_db($GLOBALS['db']);
42 // The 'show table' statement works correct since 3.23.03
43 $table_info_result = PMA_DBI_query(
44 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\';',
45 null, PMA_DBI_QUERY_STORE);
47 // need this test because when we are creating a table, we get 0 rows
48 // from the SHOW TABLE query
49 // and we don't want to mess up the $tbl_type coming from the form
51 if ($table_info_result && PMA_DBI_num_rows($table_info_result) > 0) {
52 $showtable = PMA_DBI_fetch_assoc($table_info_result);
53 PMA_DBI_free_result($table_info_result);
54 unset($table_info_result);
56 if (!isset($showtable['Type']) && isset($showtable['Engine'])) {
57 $showtable['Type'] =& $showtable['Engine'];
59 if (PMA_Table::isView($GLOBALS['db'], $GLOBALS['table'])) {
60 $tbl_is_view = true;
61 $tbl_type = $GLOBALS['strView'];
62 $show_comment = null;
63 } else {
64 $tbl_is_view = false;
65 $tbl_type = isset($showtable['Type'])
66 ? strtoupper($showtable['Type'])
67 : '';
68 // a new comment could be coming from tbl_operations.php
69 // and we want to show it in the header
70 if (isset($submitcomment) && isset($comment)) {
71 $show_comment = $comment;
72 } else {
73 $show_comment = isset($showtable['Comment'])
74 ? $showtable['Comment']
75 : '';
78 $tbl_collation = empty($showtable['Collation'])
79 ? ''
80 : $showtable['Collation'];
82 if (null === $showtable['Rows']) {
83 $showtable['Rows'] = PMA_Table::countRecords($GLOBALS['db'],
84 $showtable['Name'], true, true);
86 $table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0;
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 gloabel 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