2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays table create form and handles it
10 * Get some core libraries
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/create_addfield.lib.php';
16 PMA_Util
::checkParameters(array('db'));
18 /* Check if database name is empty */
19 if (strlen($db) == 0) {
21 __('The database name is empty!'), '', '', 'index.php'
26 * Selects the database to work with
28 if (!$GLOBALS['dbi']->selectDb($db)) {
30 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
37 if ($GLOBALS['dbi']->getColumns($db, $table)) {
38 // table exists already
40 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
43 'db_structure.php?' . PMA_URL_getCommon($db)
47 // for libraries/tbl_columns_definition_form.inc.php
48 // check number of fields to be created
49 $num_fields = PMA_getNumberOfFieldsFromRequest();
51 $action = 'tbl_create.php';
54 * The form used to define the structure of the table has been submitted
56 if (isset($_REQUEST['do_save_data'])) {
57 $sql_query = PMA_getTableCreationQuery($db, $table);
59 $result = $GLOBALS['dbi']->tryQuery($sql_query);
62 // If comments were sent, enable relation stuff
63 include_once 'libraries/transformations.lib.php';
64 // Update comment table for mime types [MIME]
65 if (isset($_REQUEST['field_mimetype'])
66 && is_array($_REQUEST['field_mimetype'])
69 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
70 if (isset($_REQUEST['field_name'][$fieldindex])
71 && strlen($_REQUEST['field_name'][$fieldindex])
74 $db, $table, $_REQUEST['field_name'][$fieldindex], $mimetype,
75 $_REQUEST['field_transformation'][$fieldindex],
76 $_REQUEST['field_transformation_options'][$fieldindex]
82 $response = PMA_Response
::getInstance();
83 $response->isSuccess(false);
84 $response->addJSON('message', $GLOBALS['dbi']->getError());
87 } // end do create table
90 * Displays the form used to define the structure of the table
92 require 'libraries/tbl_columns_definition_form.inc.php';