} // some types, for example longtext, are reported as // "longtext character set latin7" when their charset and / or collation // differs from the ones of the corresponding database. $tmp = mb_strpos($type, 'character set'); if ($tmp) { $type = mb_substr($type, 0, $tmp - 1); } // rtrim the type, for cases like "float unsigned" $type = rtrim($type); if (isset($submit_length) && $submit_length != false) { $length = $submit_length; } // Variable tell if current column is bound in a foreign key constraint or not. if (isset($columnMeta['Field']) && isset($_form_params['table'])) { $columnMeta['column_status'] = PMA_checkChildForeignReferences($_form_params['db'], $_form_params['table'], $columnMeta['Field'], $foreigners, $child_references); } // old column attributes if ($is_backup) { $_form_params = PMA_getFormParamsForOldColumn($columnMeta, $length, $_form_params, $columnNumber, $type, $extracted_columnspec); } $content_cells[$columnNumber] = PMA_getHtmlForColumnAttributes($columnNumber, isset($columnMeta) ? $columnMeta : array(), mb_strtoupper($type), $length_values_input_size, $length, isset($default_current_timestamp) ? $default_current_timestamp : null, isset($extracted_columnspec) ? $extracted_columnspec : null, isset($submit_attribute) ? $submit_attribute : null, isset($analyzed_sql) ? $analyzed_sql : null, isset($submit_default_current_timestamp) ? $submit_default_current_timestamp : null, $comments_map, isset($fields_meta) ? $fields_meta : null, $is_backup, isset($move_columns) ? $move_columns : array(), $cfgRelation, isset($available_mime) ? $available_mime : array(), isset($mime_map) ? $mime_map : array()); } // end for $html = PMA_getHtmlForTableCreateOrAddField($action, $_form_params, $content_cells, $header_cells); unset($_form_params); $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('jquery/jquery.uitablefilter.js'); $scripts->addFile('indexes.js');
/** * make the columns of given tables consistent with central list of columns. * Updates only those columns which are not being referenced. * * @param string $db current database * @param array $selected_tables list of selected tables. * * @return true|PMA\libraries\Message */ function PMA_makeConsistentWithList($db, $selected_tables) { $message = true; foreach ($selected_tables as $table) { $query = 'ALTER TABLE ' . Util::backquote($table); $has_list = PMA_getCentralColumnsFromTable($db, $table, true); $GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']); foreach ($has_list as $column) { $column_status = PMA_checkChildForeignReferences($db, $table, $column['col_name']); //column definition can only be changed if //it is not referenced by another column if ($column_status['isEditable']) { $query .= ' MODIFY ' . Util::backquote($column['col_name']) . ' ' . Util::sqlAddSlashes($column['col_type']); if ($column['col_length']) { $query .= '(' . $column['col_length'] . ')'; } $query .= ' ' . $column['col_attribute']; if ($column['col_isNull']) { $query .= ' NULL'; } else { $query .= ' NOT NULL'; } $query .= ' ' . $column['col_extra']; if ($column['col_default']) { if ($column['col_default'] != 'CURRENT_TIMESTAMP') { $query .= ' DEFAULT \'' . Util::sqlAddSlashes($column['col_default']) . '\''; } else { $query .= ' DEFAULT ' . Util::sqlAddSlashes($column['col_default']); } } $query .= ','; } } $query = trim($query, " ,") . ";"; if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['userlink'])) { if ($message === true) { $message = Message::error($GLOBALS['dbi']->getError($GLOBALS['userlink'])); } else { $message->addMessage('<br />'); $message->addMessage($GLOBALS['dbi']->getError($GLOBALS['userlink'])); } } } return $message; }