Added ability to choose the collation for new databases.
This commit is contained in:
@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2004-04-17 Alexander M. Turek <me@derrabus.de>
|
||||||
|
* db_create.php, main.php, libraries/mysql_charsets.lib.php:
|
||||||
|
Added ability to choose the collation for new databases.
|
||||||
|
|
||||||
2004-04-16 Marc Delisle <lem9@users.sourceforge.net>
|
2004-04-16 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* lang/french update
|
* lang/french update
|
||||||
|
|
||||||
|
@@ -24,8 +24,12 @@ $err_url = 'main.php?' . PMA_generate_common_url();
|
|||||||
* Builds and executes the db creation sql query
|
* Builds and executes the db creation sql query
|
||||||
*/
|
*/
|
||||||
$sql_query = 'CREATE DATABASE ' . PMA_backquote($db);
|
$sql_query = 'CREATE DATABASE ' . PMA_backquote($db);
|
||||||
if (isset($db_charset) && isset($mysql_charsets) && in_array($db_charset, $mysql_charsets)) {
|
if (!empty($db_collation) && PMA_MYSQL_INT_VERSION >= 40101) {
|
||||||
$sql_query .= ' DEFAULT CHARACTER SET ' . $db_charset;
|
list($db_charset) = explode('_', $db_collation);
|
||||||
|
if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
|
||||||
|
$sql_query .= ' DEFAULT CHARACTER SET ' . $db_charset . ' COLLATE ' . $db_collation;
|
||||||
|
}
|
||||||
|
unset($db_charset, $db_collation);
|
||||||
}
|
}
|
||||||
$sql_query .= ';';
|
$sql_query .= ';';
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40100){
|
if (PMA_MYSQL_INT_VERSION >= 40100){
|
||||||
|
|
||||||
$res = PMA_DBI_query('SHOW CHARACTER SET;', NULL, PMA_DBI_QUERY_STORE);
|
$res = PMA_DBI_query('SHOW CHARACTER SET;');
|
||||||
|
|
||||||
$mysql_charsets = array();
|
$mysql_charsets = array();
|
||||||
while ($row = PMA_DBI_fetch_assoc($res)) {
|
while ($row = PMA_DBI_fetch_assoc($res)) {
|
||||||
@@ -15,7 +15,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
|
|||||||
@PMA_DBI_free_result($res);
|
@PMA_DBI_free_result($res);
|
||||||
unset($res, $row);
|
unset($res, $row);
|
||||||
|
|
||||||
$res = PMA_DBI_query('SHOW COLLATION;', NULL, PMA_DBI_QUERY_STORE);
|
$res = PMA_DBI_query('SHOW COLLATION;');
|
||||||
|
|
||||||
$mysql_charsets_count = count($mysql_charsets);
|
$mysql_charsets_count = count($mysql_charsets);
|
||||||
sort($mysql_charsets, SORT_STRING);
|
sort($mysql_charsets, SORT_STRING);
|
||||||
@@ -252,6 +252,41 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define('PMA_CSDROPDOWN_COLLATION', 0);
|
||||||
|
define('PMA_CSDROPDOWN_CHARSET', 1);
|
||||||
|
|
||||||
|
function PMA_printCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = NULL, $id = NULL, $label = TRUE, $indent = 0) {
|
||||||
|
global $mysql_charsets, $mysql_charsets_descriptions, $mysql_collations;
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
if ($type == PMA_CSDROPDOWN_COLLATION) {
|
||||||
|
$name = 'collation';
|
||||||
|
} else {
|
||||||
|
$name = 'character_set';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ($i = 1; $i <= $indent; $i++) $spacer .= ' ';
|
||||||
|
|
||||||
|
echo $spacer . '<select name="' . htmlspecialchars($name) . '"' . (empty($id) ? '' : ' id="' . htmlspecialchars($id) . '"') . '>' . "\n";
|
||||||
|
if ($label) {
|
||||||
|
echo $spacer . ' <option value="">' . ($ype == PMA_CSDROPDOWN_COLLATION ? $GLOBALS['strCollation'] : $GLOBALS['strCharset']) . '</option>' . "\n";
|
||||||
|
}
|
||||||
|
echo $spacer . ' <option value=""></option>' . "\n";
|
||||||
|
foreach ($mysql_charsets as $current_charset) {
|
||||||
|
$current_cs_descr = empty($mysql_charsets_descriptions[$current_charset]) ? $current_charset : $mysql_charsets_descriptions[$current_charset];
|
||||||
|
if ($type == CS_DROPDOWN_COLLATION) {
|
||||||
|
echo $spacer . ' <optgroup label="' . $current_charset . '" title="' . $current_cs_descr . '">' . "\n";
|
||||||
|
foreach ($mysql_collations[$current_charset] as $current_collation) {
|
||||||
|
echo $spacer . ' <option value="' . $current_collation . '" title="' . PMA_getCollationDescr($current_collation) . '">' . $current_collation . '</option>' . "\n";
|
||||||
|
}
|
||||||
|
echo $spacer . ' </optgroup>' . "\n";
|
||||||
|
} else {
|
||||||
|
echo $spacer . ' <option value="' . $current_charset . '" title="' . $current_cs_descr . '">' . $current_charset . '</option>' . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo $spacer . '</select>' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
8
main.php
8
main.php
@@ -305,13 +305,7 @@ if ($server > 0) {
|
|||||||
. ' <input type="text" name="db" value="' . $db_to_create . '" maxlength="64" class="textfield" />' . "\n";
|
. ' <input type="text" name="db" value="' . $db_to_create . '" maxlength="64" class="textfield" />' . "\n";
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40101) {
|
if (PMA_MYSQL_INT_VERSION >= 40101) {
|
||||||
require_once('./libraries/mysql_charsets.lib.php');
|
require_once('./libraries/mysql_charsets.lib.php');
|
||||||
echo ' <select name="db_charset">' . "\n"
|
PMA_printCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', NULL, TRUE, 5);
|
||||||
. ' <option value="">' . $strCharset . '</option>' . "\n"
|
|
||||||
. ' <option value=""></option>' . "\n";
|
|
||||||
for ($i = 0; isset($mysql_charsets[$i]); $i++) {
|
|
||||||
echo ' <option value="' . htmlspecialchars($mysql_charsets[$i]) . '">' . htmlspecialchars($mysql_charsets[$i]) . '</option>' . "\n";
|
|
||||||
}
|
|
||||||
echo ' </select>' . "\n";
|
|
||||||
}
|
}
|
||||||
echo ' <input type="submit" value="' . $strCreate . '" />' . "\n"
|
echo ' <input type="submit" value="' . $strCreate . '" />' . "\n"
|
||||||
. ' </form>' . "\n"
|
. ' </form>' . "\n"
|
||||||
|
Reference in New Issue
Block a user