Translated using Weblate (Finnish)
[phpmyadmin.git] / tbl_create.php
blobebbef95151ff3b1d5da244cce0033860472a831e
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_Util::checkParameters(array('db'));
18 /** @var PMA_String $pmaString */
19 $pmaString = $GLOBALS['PMA_String'];
21 /* Check if database name is empty */
22 if (/*overload*/mb_strlen($db) == 0) {
23 PMA_Util::mysqlDie(
24 __('The database name is empty!'), '', false, 'index.php'
28 /**
29 * Selects the database to work with
31 if (!$GLOBALS['dbi']->selectDb($db)) {
32 PMA_Util::mysqlDie(
33 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
34 '',
35 false,
36 'index.php'
40 if ($GLOBALS['dbi']->getColumns($db, $table)) {
41 // table exists already
42 PMA_Util::mysqlDie(
43 sprintf(__('Table %s already exists!'), htmlspecialchars($table)),
44 '',
45 false,
46 'db_structure.php' . PMA_URL_getCommon(array('db' => $db))
50 // for libraries/tbl_columns_definition_form.inc.php
51 // check number of fields to be created
52 $num_fields = PMA_getNumberOfFieldsFromRequest();
54 $action = 'tbl_create.php';
56 /**
57 * The form used to define the structure of the table has been submitted
59 if (isset($_REQUEST['do_save_data'])) {
60 $sql_query = PMA_getTableCreationQuery($db, $table);
62 // If there is a request for SQL previewing.
63 if (isset($_REQUEST['preview_sql'])) {
64 PMA_previewSQL($sql_query);
66 // Executes the query
67 $result = $GLOBALS['dbi']->tryQuery($sql_query);
69 if ($result) {
70 // If comments were sent, enable relation stuff
71 include_once 'libraries/transformations.lib.php';
72 // Update comment table for mime types [MIME]
73 if (isset($_REQUEST['field_mimetype'])
74 && is_array($_REQUEST['field_mimetype'])
75 && $cfg['BrowseMIME']
76 ) {
77 foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
78 if (isset($_REQUEST['field_name'][$fieldindex])
79 && /*overload*/mb_strlen($_REQUEST['field_name'][$fieldindex])
80 ) {
81 PMA_setMIME(
82 $db, $table,
83 $_REQUEST['field_name'][$fieldindex], $mimetype,
84 $_REQUEST['field_transformation'][$fieldindex],
85 $_REQUEST['field_transformation_options'][$fieldindex],
86 $_REQUEST['field_input_transformation'][$fieldindex],
87 $_REQUEST['field_input_transformation_options'][$fieldindex]
92 } else {
93 $response = PMA_Response::getInstance();
94 $response->isSuccess(false);
95 $response->addJSON('message', $GLOBALS['dbi']->getError());
97 exit;
98 } // end do create table
100 //This global variable needs to be reset for the headerclass to function properly
101 $GLOBAL['table'] = '';
104 * Displays the form used to define the structure of the table
106 require 'libraries/tbl_columns_definition_form.inc.php';