#483 - New MySQL charset change command
| Identifier | #483 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | New MySQL charset change command |
| Status | Closed (rejected) |
| Handling member | Chris Graham |
| Addon | commandr |
| Description | Command to change everything about a character set. Takes charset param, defaults to utf-8. |
| Steps to reproduce | |
| Additional information | Outline...
$charset='utf8'; header('Content-Type: text/plain'); $GLOBALS['NO_DB_SCOPE_CHECK']=true; $GLOBALS['SITE_DB']->query('ALTER DATABASE '.get_db_site().' DEFAULT CHARACTER SET '.filter_naughty($charset)); echo "Converted DB, sets default for new tables\n"; $tables=$GLOBALS['SITE_DB']->query_select('db_meta',array('DISTINCT m_table'),NULL,'ORDER BY m_table'); foreach ($tables as $table) { $GLOBALS['SITE_DB']->query('ALTER TABLE '.get_table_prefix().$table['m_table'].' CONVERT TO CHARACTER SET '.filter_naughty($charset)); echo 'Converted '.$table['m_table']."\n"; } $contents=file_get_contents(get_file_base().'/info.php'); if (strpos($contents,'$SITE_INFO[\'database_charset\']=')!==false) { $contents=preg_replace('#\$SITE_INFO\[\'database_charset\']=\'[\w\-]+\';','$SITE_INFO[\'database_charset\']=\''.filter_naughty($charset).'\';',$contents); file_put_contents($contents,$contents); echo 'Told info.php new charset\n"; } // TODO... Go through each lang pack, checking it is right charset, if not update Also ideally needs a parameter to force cleanup of literally-stored utf8 data in non-utf8 tables (does binary charset change). Document all this in the internationalisation tutorial. |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".
Comments
Plus people can do an export then re-import into a new DB, if they need to switch the DBs charset.
So it's not an awful situation. I'd still love this Commandr command to exist. Probably next time I need to do a conversion I'll write the command and use it.