function _flashnode_update_utf8 in Flash Node 5.6
Same name and namespace in other branches
- 5.2 flashnode.install \_flashnode_update_utf8()
- 5.3 flashnode.install \_flashnode_update_utf8()
Convert a 4.7 table to UTF-8 as part of installation as we won't get it via update.php
This code taken from install.inc and we have to repeat it here as it is not available to us during a module install, only module update, but we might need to migrate the table over
1 call to _flashnode_update_utf8()
- _flashnode_migrate_from_flash in ./
flashnode.install - If flashnode is being installed in place of flash then to Drupal it looks like the first time this module has been installed. In reality we have an existing table we want to keep with our existing flash content, so we have to simulate the update…
File
- ./
flashnode.install, line 376
Code
function _flashnode_update_utf8() {
switch ($GLOBALS['db_type']) {
// Only for MySQL 4.1+
case 'mysqli':
break;
case 'mysql':
if (version_compare(mysql_get_server_info($GLOBALS['active_db']), '4.1.0', '<')) {
return;
}
break;
case 'pgsql':
return;
}
// See if database uses UTF-8 already
global $db_url;
$url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
$db_name = substr($url['path'], 1);
$result = db_fetch_array(db_query('SHOW CREATE DATABASE `%s`', $db_name));
if (preg_match('/utf8/i', array_pop($result))) {
return;
}
db_query('ALTER TABLE {flash} DEFAULT CHARACTER SET utf8');
return;
}