Converting number of Excel column names no longer limited
[phpmyadmin/arisferyanto.git] / libraries / tbl_info.inc.php
blob5151acb08b6bede777f2d08b8909ec1aa2e10384
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 * @version $Id$
10 * @package phpMyAdmin
12 if (! defined('PHPMYADMIN')) {
13 exit;
16 /**
19 require_once './libraries/Table.class.php';
21 /**
22 * requirements
24 require_once './libraries/common.inc.php';
26 // Check parameters
27 PMA_checkParameters(array('db', 'table'));
29 /**
30 * Defining global variables, in case this script is included by a function.
31 * This is necessary because this script can be included by libraries/header.inc.php.
33 global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
34 $table_info_num_rows, $auto_increment;
36 /**
37 * Gets table informations
39 // Seems we need to do this in MySQL 5.0.2,
40 // otherwise error #1046, no database selected
41 PMA_DBI_select_db($GLOBALS['db']);
44 /**
45 * Holds information about the current table
47 * @todo replace this by PMA_Table
48 * @global array $GLOBALS['showtable']
49 * @name $showtable
51 $GLOBALS['showtable'] = array();
53 // PMA_Table::sGetStatusInfo() does caching by default, but here
54 // we force reading of the current table status
55 // if $reread_info is true (for example, coming from tbl_operations.php
56 // and we just changed the table's storage engine)
57 $GLOBALS['showtable'] = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, (isset($reread_info) && $reread_info ? true : false));
59 // need this test because when we are creating a table, we get 0 rows
60 // from the SHOW TABLE query
61 // and we don't want to mess up the $tbl_type coming from the form
63 if ($showtable) {
64 if (PMA_Table::isView($GLOBALS['db'], $GLOBALS['table'])) {
65 $tbl_is_view = true;
66 $tbl_type = $GLOBALS['strView'];
67 $show_comment = null;
68 } else {
69 $tbl_is_view = false;
70 $tbl_type = isset($showtable['Engine'])
71 ? strtoupper($showtable['Engine'])
72 : '';
73 // a new comment could be coming from tbl_operations.php
74 // and we want to show it in the header
75 if (isset($submitcomment) && isset($comment)) {
76 $show_comment = $comment;
77 } else {
78 $show_comment = isset($showtable['Comment'])
79 ? $showtable['Comment']
80 : '';
83 $tbl_collation = empty($showtable['Collation'])
84 ? ''
85 : $showtable['Collation'];
87 if (null === $showtable['Rows']) {
88 $showtable['Rows'] = PMA_Table::countRecords($GLOBALS['db'],
89 $showtable['Name'], true);
91 $table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0;
92 $row_format = isset($showtable['Row_format']) ? $showtable['Row_format'] : '';
93 $auto_increment = isset($showtable['Auto_increment'])
94 ? $showtable['Auto_increment']
95 : '';
97 $create_options = isset($showtable['Create_options'])
98 ? explode(' ', $showtable['Create_options'])
99 : array();
101 // export create options by its name as variables into global namespace
102 // f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
103 unset($pack_keys);
104 foreach ($create_options as $each_create_option) {
105 $each_create_option = explode('=', $each_create_option);
106 if (isset($each_create_option[1])) {
107 $$each_create_option[0] = $each_create_option[1];
110 // we need explicit DEFAULT value here (different from '0')
111 $pack_keys = (!isset($pack_keys) || strlen($pack_keys) == 0) ? 'DEFAULT' : $pack_keys;
112 unset($create_options, $each_create_option);
113 } // end if