2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays table create form and handles it
10 use PhpMyAdmin\CreateAddField
;
11 use PhpMyAdmin\Response
;
12 use PhpMyAdmin\Transformations
;
17 * Get some core libraries
19 require_once 'libraries/common.inc.php';
22 Util
::checkParameters(array('db'));
24 /* Check if database name is empty */
25 if (strlen($db) === 0) {
27 __('The database name is empty!'), '', false, 'index.php'
32 * Selects the database to work with
34 if (!$GLOBALS['dbi']->selectDb($db)) {
36 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
43 if ($GLOBALS['dbi']->getColumns($db, $table)) {
44 // table exists already
46 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
49 'db_structure.php' . Url
::getCommon(array('db' => $db))
53 $createAddField = new CreateAddField($GLOBALS['dbi']);
55 // for libraries/tbl_columns_definition_form.inc.php
56 // check number of fields to be created
57 $num_fields = $createAddField->getNumberOfFieldsFromRequest();
59 $action = 'tbl_create.php';
62 * The form used to define the structure of the table has been submitted
64 if (isset($_POST['do_save_data'])) {
65 $sql_query = $createAddField->getTableCreationQuery($db, $table);
67 // If there is a request for SQL previewing.
68 if (isset($_POST['preview_sql'])) {
69 Core
::previewSQL($sql_query);
72 $result = $GLOBALS['dbi']->tryQuery($sql_query);
75 // Update comment table for mime types [MIME]
76 if (isset($_POST['field_mimetype'])
77 && is_array($_POST['field_mimetype'])
80 foreach ($_POST['field_mimetype'] as $fieldindex => $mimetype) {
81 if (isset($_POST['field_name'][$fieldindex])
82 && strlen($_POST['field_name'][$fieldindex]) > 0
84 Transformations
::setMIME(
86 $_POST['field_name'][$fieldindex], $mimetype,
87 $_POST['field_transformation'][$fieldindex],
88 $_POST['field_transformation_options'][$fieldindex],
89 $_POST['field_input_transformation'][$fieldindex],
90 $_POST['field_input_transformation_options'][$fieldindex]
96 $response = Response
::getInstance();
97 $response->setRequestStatus(false);
98 $response->addJSON('message', $GLOBALS['dbi']->getError());
101 } // end do create table
103 //This global variable needs to be reset for the headerclass to function properly
104 $GLOBAL['table'] = '';
107 * Displays the form used to define the structure of the table
109 require 'libraries/tbl_columns_definition_form.inc.php';