Translated using Weblate (Slovenian)
[phpmyadmin.git] / tbl_create.php
blob882d8736778b03840ca058ba6558ebc2d3d52b56
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 */
8 use PMA\libraries\URL;
9 use PMA\libraries\Response;
11 /**
12 * Get some core libraries
14 require_once 'libraries/common.inc.php';
15 require_once 'libraries/create_addfield.lib.php';
17 // Check parameters
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'
27 /**
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)),
33 '',
34 false,
35 'index.php'
39 if ($GLOBALS['dbi']->getColumns($db, $table)) {
40 // table exists already
41 PMA\libraries\Util::mysqlDie(
42 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
43 '',
44 false,
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';
55 /**
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);
65 // Executes the query
66 $result = $GLOBALS['dbi']->tryQuery($sql_query);
68 if ($result) {
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'])
74 && $cfg['BrowseMIME']
75 ) {
76 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
77 if (isset($_REQUEST['field_name'][$fieldindex])
78 && strlen($_REQUEST['field_name'][$fieldindex]) > 0
79 ) {
80 PMA_setMIME(
81 $db, $table,
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]
91 } else {
92 $response = Response::getInstance();
93 $response->setRequestStatus(false);
94 $response->addJSON('message', $GLOBALS['dbi']->getError());
96 exit;
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';