2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays table create form and handles it
9 use PMA\libraries\Response
;
12 * Get some core libraries
14 require_once 'libraries/common.inc.php';
15 require_once 'libraries/create_addfield.lib.php';
18 PMA\libraries\Util
::checkParameters(array('db'));
20 /* Check if database name is empty */
21 if (strlen($db) === 0) {
22 PMA\libraries\Util
::mysqlDie(
23 __('The database name is empty!'), '', false, 'index.php'
28 * Selects the database to work with
30 if (!$GLOBALS['dbi']->selectDb($db)) {
31 PMA\libraries\Util
::mysqlDie(
32 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
39 if ($GLOBALS['dbi']->getColumns($db, $table)) {
40 // table exists already
41 PMA\libraries\Util
::mysqlDie(
42 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
45 'db_structure.php' . URL
::getCommon(array('db' => $db))
49 // for libraries/tbl_columns_definition_form.inc.php
50 // check number of fields to be created
51 $num_fields = PMA_getNumberOfFieldsFromRequest();
53 $action = 'tbl_create.php';
56 * The form used to define the structure of the table has been submitted
58 if (isset($_REQUEST['do_save_data'])) {
59 $sql_query = PMA_getTableCreationQuery($db, $table);
61 // If there is a request for SQL previewing.
62 if (isset($_REQUEST['preview_sql'])) {
63 PMA_previewSQL($sql_query);
66 $result = $GLOBALS['dbi']->tryQuery($sql_query);
69 // If comments were sent, enable relation stuff
70 include_once 'libraries/transformations.lib.php';
71 // Update comment table for mime types [MIME]
72 if (isset($_REQUEST['field_mimetype'])
73 && is_array($_REQUEST['field_mimetype'])
76 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
77 if (isset($_REQUEST['field_name'][$fieldindex])
78 && strlen($_REQUEST['field_name'][$fieldindex]) > 0
82 $_REQUEST['field_name'][$fieldindex], $mimetype,
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 $response = Response
::getInstance();
93 $response->setRequestStatus(false);
94 $response->addJSON('message', $GLOBALS['dbi']->getError());
97 } // end do create table
99 //This global variable needs to be reset for the headerclass to function properly
100 $GLOBAL['table'] = '';
103 * Displays the form used to define the structure of the table
105 require 'libraries/tbl_columns_definition_form.inc.php';