2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays add field form and handles it
9 use PhpMyAdmin\Response
;
10 use PhpMyAdmin\Transformations
;
14 * Get some core libraries
16 require_once 'libraries/common.inc.php';
18 $response = Response
::getInstance();
19 $header = $response->getHeader();
20 $scripts = $header->getScripts();
21 $scripts->addFile('tbl_structure.js');
24 PhpMyAdmin\Util
::checkParameters(array('db', 'table'));
28 * Defines the url to return to in case of error in a sql statement
30 $err_url = 'tbl_sql.php' . Url
::getCommon(
32 'db' => $db, 'table' => $table
37 * The form used to define the field to add has been submitted
41 // check number of fields to be created
42 if (isset($_REQUEST['submit_num_fields'])) {
43 if (isset($_REQUEST['orig_after_field'])) {
44 $_REQUEST['after_field'] = $_REQUEST['orig_after_field'];
46 if (isset($_REQUEST['orig_field_where'])) {
47 $_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
50 intval($_REQUEST['orig_num_fields']) +
intval($_REQUEST['added_fields']),
54 } elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
55 $num_fields = min(4096, intval($_REQUEST['num_fields']));
60 if (isset($_REQUEST['do_save_data'])) {
61 //avoid an incorrect calling of PMA_updateColumns() via
62 //tbl_structure.php below
63 unset($_REQUEST['do_save_data']);
65 include_once 'libraries/create_addfield.lib.php';
67 list($result, $sql_query) = PMA_tryColumnCreationQuery($db, $table, $err_url);
69 if ($result === true) {
70 // Update comment table for mime types [MIME]
71 if (isset($_REQUEST['field_mimetype'])
72 && is_array($_REQUEST['field_mimetype'])
75 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
76 if (isset($_REQUEST['field_name'][$fieldindex])
77 && strlen($_REQUEST['field_name'][$fieldindex]) > 0
79 Transformations
::setMIME(
81 $_REQUEST['field_name'][$fieldindex],
83 $_REQUEST['field_transformation'][$fieldindex],
84 $_REQUEST['field_transformation_options'][$fieldindex],
85 $_REQUEST['field_input_transformation'][$fieldindex],
86 $_REQUEST['field_input_transformation_options'][$fieldindex]
92 // Go back to the structure sub-page
93 $message = PhpMyAdmin\Message
::success(
94 __('Table %1$s has been altered successfully.')
96 $message->addParam($table);
99 PhpMyAdmin\Util
::getMessage($message, $sql_query, 'success')
103 $error_message_html = PhpMyAdmin\Util
::mysqlDie(
110 $response->addHTML($error_message_html);
111 $response->setRequestStatus(false);
114 } // end do alter table
117 * Displays the form used to define the new field
119 if ($abort == false) {
121 * Gets tables information
123 include_once 'libraries/tbl_common.inc.php';
125 $active_page = 'tbl_structure.php';
129 $action = 'tbl_addfield.php';
130 include_once 'libraries/tbl_columns_definition_form.inc.php';