Suggestion: make chosing MySQL collation easier
Database management in a single PHP file
Brought to you by:
jakubvrana
Since there are a lot of collations in MySQL, it's a real pain to pick the frequently used UTF-8 and UTF8 unicode ci collations, which are used frequently.
So I made a test, modified the source code to include the favorites at the very beginning of the list:
File drivers/mysql.inc.php, Line 556, function collarions()
function collations() {
$return = array();
$favorites = array(
'ascii_bin',
'ascii_general_ci',
'utf8_bin',
'utf8_unicode_ci',
);
foreach (get_rows("SHOW COLLATION") as $row) {
if (in_array($row["Collation"], $favorites)) {
$return['#Favorites'][] = $row["Collation"];
} elseif ($row["Default"]) {
$return[$row["Charset"]][-1] = $row["Collation"];
} else {
$return[$row["Charset"]][] = $row["Collation"];
}
}
ksort($return);
foreach ($return as $key => $val) {
asort($return[$key]);
}
return $return;
}
$return['#Favorites'] may be renamed to $return['#Frequently used']
See the attached png.
It's possible to search in the list by typing.
Also, setting the collation for the server sets the default for the newly created databases, database for the tables and table for columns. So you don't really need to set the collation that often.
I am not comfortable with this change as different people can have different favorites. If you want to pursue this idea, send a pull request solving this in a plugin, not in the main Adminer code. You'll probably need to add a new method to the
Adminerclass and call it fromcollations().In fact, the all current db standards recommend to use utf-8 or utf-16, (beside plain ascii) so I still think it's a good idea to bring to the front the generic/most used collations, instead of burrying them deep betwen all kind of language collations.
My point is that in most cases, you don't need to select anything and the default (from the server, database or table) is used.