Translation update done using Pootle.
[phpmyadmin-themes.git] / db_create.php
blob50e4cf67d129cad5c6f55d1fda2d89e446fae7b2
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
9 * Gets some core libraries
11 require_once './libraries/common.inc.php';
12 require_once './libraries/mysql_charsets.lib.php';
14 PMA_checkParameters(array('new_db'));
16 /**
17 * Defines the url to return to in case of error in a sql statement
19 $err_url = 'main.php?' . PMA_generate_common_url();
21 /**
22 * Builds and executes the db creation sql query
24 $sql_query = 'CREATE DATABASE ' . PMA_backquote($new_db);
25 if (!empty($db_collation)) {
26 list($db_charset) = explode('_', $db_collation);
27 if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
28 $sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
30 unset($db_charset, $db_collation);
32 $sql_query .= ';';
34 $result = PMA_DBI_try_query($sql_query);
36 if (! $result) {
37 $message = PMA_Message::rawError(PMA_DBI_getError());
38 // avoid displaying the not-created db name in header or navi panel
39 $GLOBALS['db'] = '';
40 $GLOBALS['table'] = '';
41 require_once './libraries/header.inc.php';
42 require_once './main.php';
43 } else {
44 $message = PMA_Message::success(__('Database %1$s has been created.'));
45 $message->addParam($new_db);
46 $GLOBALS['db'] = $new_db;
48 require_once './libraries/header.inc.php';
49 require_once './' . $cfg['DefaultTabDatabase'];