Translated using Weblate (Ukrainian)
[phpmyadmin.git] / tbl_create.php
blobd9160a6d12334a4ae675ce246bf03932bf77b01e
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 use PhpMyAdmin\Core;
10 use PhpMyAdmin\CreateAddField;
11 use PhpMyAdmin\Response;
12 use PhpMyAdmin\Transformations;
13 use PhpMyAdmin\Url;
14 use PhpMyAdmin\Util;
16 /**
17 * Get some core libraries
19 require_once 'libraries/common.inc.php';
21 // Check parameters
22 Util::checkParameters(array('db'));
24 /* Check if database name is empty */
25 if (strlen($db) === 0) {
26 Util::mysqlDie(
27 __('The database name is empty!'), '', false, 'index.php'
31 /**
32 * Selects the database to work with
34 if (!$GLOBALS['dbi']->selectDb($db)) {
35 Util::mysqlDie(
36 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
37 '',
38 false,
39 'index.php'
43 if ($GLOBALS['dbi']->getColumns($db, $table)) {
44 // table exists already
45 Util::mysqlDie(
46 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
47 '',
48 false,
49 'db_structure.php' . Url::getCommon(array('db' => $db))
53 // for libraries/tbl_columns_definition_form.inc.php
54 // check number of fields to be created
55 $num_fields = CreateAddField::getNumberOfFieldsFromRequest();
57 $action = 'tbl_create.php';
59 /**
60 * The form used to define the structure of the table has been submitted
62 if (isset($_REQUEST['do_save_data'])) {
63 $sql_query = CreateAddField::getTableCreationQuery($db, $table);
65 // If there is a request for SQL previewing.
66 if (isset($_REQUEST['preview_sql'])) {
67 Core::previewSQL($sql_query);
69 // Executes the query
70 $result = $GLOBALS['dbi']->tryQuery($sql_query);
72 if ($result) {
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 && strlen($_REQUEST['field_name'][$fieldindex]) > 0
81 ) {
82 Transformations::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 = 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';