/** * Returns the generation expression for virtual columns * * @param string $column name of the column * * @return array|boolean associative array of column name and their expressions * or false on failure */ public function getColumnGenerationExpression($column = null) { $serverType = PMA_Util::getServerType(); if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION > 50705 && !$GLOBALS['cfg']['Server']['DisableIS']) { $sql = "SELECT\r\n `COLUMN_NAME` AS `Field`,\r\n `GENERATION_EXPRESSION` AS `Expression`\r\n FROM\r\n `information_schema`.`COLUMNS`\r\n WHERE\r\n `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($this->_db_name) . "'\r\n AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($this->_name) . "'"; if ($column != null) { $sql .= " AND `COLUMN_NAME` = '" . PMA_Util::sqlAddSlashes($column) . "'"; } $columns = $this->_dbi->fetchResult($sql, 'Field', 'Expression'); return $columns; } $createTable = $this->showCreate(); if (!$createTable) { return false; } $parser = new SqlParser\Parser($createTable); /** * @var SqlParser\Statements\CreateStatement $stmt */ $stmt = $parser->statements[0]; $fields = SqlParser\Utils\Table::getFields($stmt); if ($column != null) { $expression = isset($fields[$column]['expr']) ? substr($fields[$column]['expr'], 1, -1) : ''; return array($column => $expression); } $ret = array(); foreach ($fields as $field => $options) { if (isset($options['expr'])) { $ret[$field] = substr($options['expr'], 1, -1); } } return $ret; }
$primary = PMA_Index::getPrimary($table, $db); $columns_with_index = PMA_getColumnsWithIndex($db, $table, PMA_Index::UNIQUE | PMA_Index::INDEX | PMA_Index::SPATIAL | PMA_Index::FULLTEXT); $columns_with_unique_index = PMA_getColumnsWithIndex($db, $table, PMA_Index::UNIQUE); // 3. Get fields $fields = (array) $GLOBALS['dbi']->getColumns($db, $table, null, true); // Get more complete field information // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options // but later, if the analyser returns more information, it // could be executed for any MySQL version and replace // the info given by SHOW FULL COLUMNS FROM. // // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since // SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL // and SHOW CREATE TABLE says NOT NULL (tested // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910). $tableObj = new PMA_Table($table, $db); $show_create_table = $tableObj->showCreate(); $parser = new SqlParser\Parser($show_create_table); /** * @var CreateStatement $stmt */ $stmt = $parser->statements[0]; $create_table_fields = SqlParser\Utils\Table::getFields($stmt); /** * prepare table infos */ // action titles (image or string) $titles = PMA_getActionTitlesArray(); //display table structure require_once 'libraries/display_structure.inc.php'; $response->addHTML('</div>');