Translated using Weblate (Slovenian)
[phpmyadmin.git] / tbl_create.php
blobc465c28cf77402bd72a6b920a75d55a9537e8af9
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays table create form and handles it
6 * @package PhpMyAdmin
7 */
9 /**
10 * Get some core libraries
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/create_addfield.lib.php';
15 // Check parameters
16 PMA\libraries\Util::checkParameters(array('db'));
18 /* Check if database name is empty */
19 if (mb_strlen($db) == 0) {
20 PMA\libraries\Util::mysqlDie(
21 __('The database name is empty!'), '', false, 'index.php'
25 /**
26 * Selects the database to work with
28 if (!$GLOBALS['dbi']->selectDb($db)) {
29 PMA\libraries\Util::mysqlDie(
30 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
31 '',
32 false,
33 'index.php'
37 if ($GLOBALS['dbi']->getColumns($db, $table)) {
38 // table exists already
39 PMA\libraries\Util::mysqlDie(
40 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
41 '',
42 false,
43 'db_structure.php' . PMA_URL_getCommon(array('db' => $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';
53 /**
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 // If there is a request for SQL previewing.
60 if (isset($_REQUEST['preview_sql'])) {
61 PMA_previewSQL($sql_query);
63 // Executes the query
64 $result = $GLOBALS['dbi']->tryQuery($sql_query);
66 if ($result) {
67 // If comments were sent, enable relation stuff
68 include_once 'libraries/transformations.lib.php';
69 // Update comment table for mime types [MIME]
70 if (isset($_REQUEST['field_mimetype'])
71 && is_array($_REQUEST['field_mimetype'])
72 && $cfg['BrowseMIME']
73 ) {
74 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
75 if (isset($_REQUEST['field_name'][$fieldindex])
76 && mb_strlen($_REQUEST['field_name'][$fieldindex])
77 ) {
78 PMA_setMIME(
79 $db, $table,
80 $_REQUEST['field_name'][$fieldindex], $mimetype,
81 $_REQUEST['field_transformation'][$fieldindex],
82 $_REQUEST['field_transformation_options'][$fieldindex],
83 $_REQUEST['field_input_transformation'][$fieldindex],
84 $_REQUEST['field_input_transformation_options'][$fieldindex]
89 } else {
90 $response = PMA\libraries\Response::getInstance();
91 $response->setRequestStatus(false);
92 $response->addJSON('message', $GLOBALS['dbi']->getError());
94 exit;
95 } // end do create table
97 //This global variable needs to be reset for the headerclass to function properly
98 $GLOBAL['table'] = '';
101 * Displays the form used to define the structure of the table
103 require 'libraries/tbl_columns_definition_form.inc.php';