Translated using Weblate (Slovenian)
[phpmyadmin.git] / tbl_create.php
blob10612d80f173a0be4507859c7fe8d8f149c8a0bd
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\PMA_String;
10 /**
11 * Get some core libraries
13 require_once 'libraries/common.inc.php';
14 require_once 'libraries/create_addfield.lib.php';
16 // Check parameters
17 PMA\libraries\Util::checkParameters(array('db'));
19 /** @var String $pmaString */
20 $pmaString = $GLOBALS['PMA_String'];
22 /* Check if database name is empty */
23 if (/*overload*/mb_strlen($db) == 0) {
24 PMA\libraries\Util::mysqlDie(
25 __('The database name is empty!'), '', false, 'index.php'
29 /**
30 * Selects the database to work with
32 if (!$GLOBALS['dbi']->selectDb($db)) {
33 PMA\libraries\Util::mysqlDie(
34 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
35 '',
36 false,
37 'index.php'
41 if ($GLOBALS['dbi']->getColumns($db, $table)) {
42 // table exists already
43 PMA\libraries\Util::mysqlDie(
44 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
45 '',
46 false,
47 'db_structure.php' . PMA_URL_getCommon(array('db' => $db))
51 // for libraries/tbl_columns_definition_form.inc.php
52 // check number of fields to be created
53 $num_fields = PMA_getNumberOfFieldsFromRequest();
55 $action = 'tbl_create.php';
57 /**
58 * The form used to define the structure of the table has been submitted
60 if (isset($_REQUEST['do_save_data'])) {
61 $sql_query = PMA_getTableCreationQuery($db, $table);
63 // If there is a request for SQL previewing.
64 if (isset($_REQUEST['preview_sql'])) {
65 PMA_previewSQL($sql_query);
67 // Executes the query
68 $result = $GLOBALS['dbi']->tryQuery($sql_query);
70 if ($result) {
71 // If comments were sent, enable relation stuff
72 include_once 'libraries/transformations.lib.php';
73 // Update comment table for mime types [MIME]
74 if (isset($_REQUEST['field_mimetype'])
75 && is_array($_REQUEST['field_mimetype'])
76 && $cfg['BrowseMIME']
77 ) {
78 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
79 if (isset($_REQUEST['field_name'][$fieldindex])
80 && /*overload*/mb_strlen($_REQUEST['field_name'][$fieldindex])
81 ) {
82 PMA_setMIME(
83 $db, $table,
84 $_REQUEST['field_name'][$fieldindex], $mimetype,
85 $_REQUEST['field_transformation'][$fieldindex],
86 $_REQUEST['field_transformation_options'][$fieldindex],
87 $_REQUEST['field_input_transformation'][$fieldindex],
88 $_REQUEST['field_input_transformation_options'][$fieldindex]
93 } else {
94 $response = PMA\libraries\Response::getInstance();
95 $response->setRequestStatus(false);
96 $response->addJSON('message', $GLOBALS['dbi']->getError());
98 exit;
99 } // end do create table
101 //This global variable needs to be reset for the headerclass to function properly
102 $GLOBAL['table'] = '';
105 * Displays the form used to define the structure of the table
107 require 'libraries/tbl_columns_definition_form.inc.php';