From df3982dd8b0ea6d958e37d4ed2d94a8050e9c1d7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 11 Dec 2003 23:16:22 +0000 Subject: [PATCH] MySQL 4.1.1 compatibility, part II: Ability to specify a default character set for a new database. --- ChangeLog | 4 +++- db_create.php | 10 ++++++++-- main.php | 41 +++++++++++++++++++++++++---------------- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index a86e320e8..db7ece75a 100755 --- a/ChangeLog +++ b/ChangeLog @@ -17,10 +17,12 @@ $Source$ 2003-12-11 Alexander M. Turek * server_collations.php, lang/*.inc.php, libraries/mysql_charsets.lib.php: Updated character sets overview for MySQL 4.1.1. + * db_create.php, main.php: Ability to specify a default character set for a + new database. 2003-12-11 Garvin Hicking * header_printview.inc.php: RFE #856503, show number of rows in printview - * tbl_change.php, tbl_replace.php, tbl_replace_fields.php: Fixed #857445, + * tbl_change.php, tbl_replace.php, tbl_replace_fields.php: Fixed #857445, #857684 where non-existant fields caused PHP notices. * db_details.php: Removed unneccessary whitespace * sql.php: Bug #857742: When dropping the only remaining database, an diff --git a/db_create.php b/db_create.php index 65ba9c121..1e6054004 100644 --- a/db_create.php +++ b/db_create.php @@ -10,6 +10,7 @@ require_once('./libraries/grab_globals.lib.php'); $js_to_run = 'functions.js'; require_once('./header.inc.php'); require_once('./libraries/common.lib.php'); +require_once('./libraries/mysql_charsets.lib.php'); PMA_checkParameters(array('db')); @@ -20,10 +21,15 @@ PMA_checkParameters(array('db')); $err_url = 'main.php?' . PMA_generate_common_url(); /** - * Executes the db creation sql query + * Builds and executes the db creation sql query */ $sql_query = 'CREATE DATABASE ' . PMA_backquote($db); -$result = PMA_mysql_query('CREATE DATABASE ' . PMA_backquote($db)) or PMA_mysqlDie('', $sql_query, FALSE, $err_url); +if (isset($db_charset) && isset($mysql_charsets) && in_array($db_charset, $mysql_charsets)) { + $sql_query .= ' DEFAULT CHARACTER SET ' . $db_charset; +} +$sql_query .= ';'; + +$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, FALSE, $err_url); /** diff --git a/main.php b/main.php index 20a5f2bd7..dbd787e2a 100644 --- a/main.php +++ b/main.php @@ -292,22 +292,31 @@ if ($server > 0) { - - - item - -
-
- - - - -
- - - ' . "\n" + . ' ' . "\n" + . ' item' . "\n" + . ' ' . "\n" + . '
' . "\n" + . ' ' . $strCreateNewDatabase . ' ' . PMA_showMySQLDocu('Reference', 'CREATE_DATABASE') . "\n" + . '
' . "\n" + . PMA_generate_common_hidden_inputs(5) + . ' ' . "\n" + . ' ' . "\n"; + if (PMA_MYSQL_INT_VERSION >= 40101) { + require_once('./libraries/mysql_charsets.lib.php'); + echo ' ' . "\n"; + } + echo ' ' . "\n" + . '
' . "\n" + . ' ' . "\n" + . ' ' . "\n"; } else { echo "\n"; ?>