2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays add field form and handles it
11 * Get some core libraries
13 require_once 'libraries/common.inc.php';
15 $response = PMA\libraries\Response
::getInstance();
16 $header = $response->getHeader();
17 $scripts = $header->getScripts();
18 $scripts->addFile('tbl_structure.js');
21 PMA\libraries\Util
::checkParameters(array('db', 'table'));
25 * Defines the url to return to in case of error in a sql statement
27 $err_url = 'tbl_sql.php' . URL
::getCommon(
29 'db' => $db, 'table' => $table
34 * The form used to define the field to add has been submitted
38 // check number of fields to be created
39 if (isset($_REQUEST['submit_num_fields'])) {
40 if (isset($_REQUEST['orig_after_field'])) {
41 $_REQUEST['after_field'] = $_REQUEST['orig_after_field'];
43 if (isset($_REQUEST['orig_field_where'])) {
44 $_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
46 $num_fields = $_REQUEST['orig_num_fields'] +
$_REQUEST['added_fields'];
48 } elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
49 $num_fields = (int) $_REQUEST['num_fields'];
54 if (isset($_REQUEST['do_save_data'])) {
55 //avoid an incorrect calling of PMA_updateColumns() via
56 //tbl_structure.php below
57 unset($_REQUEST['do_save_data']);
59 include_once 'libraries/create_addfield.lib.php';
61 list($result, $sql_query) = PMA_tryColumnCreationQuery($db, $table, $err_url);
63 if ($result === true) {
64 // If comments were sent, enable relation stuff
65 include_once 'libraries/transformations.lib.php';
67 // Update comment table for mime types [MIME]
68 if (isset($_REQUEST['field_mimetype'])
69 && is_array($_REQUEST['field_mimetype'])
72 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
73 if (isset($_REQUEST['field_name'][$fieldindex])
74 && mb_strlen($_REQUEST['field_name'][$fieldindex])
78 $_REQUEST['field_name'][$fieldindex],
80 $_REQUEST['field_transformation'][$fieldindex],
81 $_REQUEST['field_transformation_options'][$fieldindex],
82 $_REQUEST['field_input_transformation'][$fieldindex],
83 $_REQUEST['field_input_transformation_options'][$fieldindex]
89 // Go back to the structure sub-page
90 $message = PMA\libraries\Message
::success(
91 __('Table %1$s has been altered successfully.')
93 $message->addParam($table);
96 PMA\libraries\Util
::getMessage($message, $sql_query, 'success')
100 $error_message_html = PMA\libraries\Util
::mysqlDie(
107 $response->addHTML($error_message_html);
108 $response->setRequestStatus(false);
111 } // end do alter table
114 * Displays the form used to define the new field
116 if ($abort == false) {
118 * Gets tables information
120 include_once 'libraries/tbl_common.inc.php';
121 include_once 'libraries/tbl_info.inc.php';
123 $active_page = 'tbl_structure.php';
127 $action = 'tbl_addfield.php';
128 include_once 'libraries/tbl_columns_definition_form.inc.php';