Hungarian update
[phpmyadmin/crack.git] / libraries / tbl_info.inc.php
blob11f91c1f9660938599b45223c125546a2c1dee5e
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$
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
18 require_once './libraries/Table.class.php';
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 // PMA_Table::sGetStatusInfo() does caching by default, but here
43 // we force reading of the current table status
44 // if $reread_info is true (for example, coming from tbl_operations.php
45 // and we just changed the table's storage engine)
46 $showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, (isset($reread_info) && $reread_info ? true : false));
48 // need this test because when we are creating a table, we get 0 rows
49 // from the SHOW TABLE query
50 // and we don't want to mess up the $tbl_type coming from the form
52 if ($showtable) {
53 if (PMA_Table::isView($GLOBALS['db'], $GLOBALS['table'])) {
54 $tbl_is_view = true;
55 $tbl_type = $GLOBALS['strView'];
56 $show_comment = null;
57 } else {
58 $tbl_is_view = false;
59 $tbl_type = isset($showtable['Engine'])
60 ? strtoupper($showtable['Engine'])
61 : '';
62 // a new comment could be coming from tbl_operations.php
63 // and we want to show it in the header
64 if (isset($submitcomment) && isset($comment)) {
65 $show_comment = $comment;
66 } else {
67 $show_comment = isset($showtable['Comment'])
68 ? $showtable['Comment']
69 : '';
72 $tbl_collation = empty($showtable['Collation'])
73 ? ''
74 : $showtable['Collation'];
76 if (null === $showtable['Rows']) {
77 $showtable['Rows'] = PMA_Table::countRecords($GLOBALS['db'],
78 $showtable['Name'], true, 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']
84 : '';
86 $create_options = isset($showtable['Create_options'])
87 ? explode(' ', $showtable['Create_options'])
88 : array();
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'
92 unset($pack_keys);
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) ? 'DEFAULT' : $pack_keys;
101 unset($create_options, $each_create_option);
102 } // end if