Wordprss
For Wordpres, the modification is straight-forward.
- Open up ‘wp-config.php’ from the root directory of your WordPress installation.
- Comment out the following lines by adding ‘//’ at the very beginning of the following two lines:
define('DB_CHARSET', 'utf8');
define(’DB_COLLATE’, ”);
So that section should now look like this:
//define('DB_CHARSET', 'utf8');
//define(’DB_COLLATE’, ”);
[Source: http://hansengel.wordpress.com/2007/10/09/wordpress-unicode-and-s/]
Drupal
For Drupal, the change is a bit more involved:
- Go to to the root directory of your Drupal installation.
- Save the following code in a file named collate_db.php
<?php
# Do not change anything below this ( :-) <- Rewwrite Editors note.)
require_once("includes/bootstrap.inc");
require_once("includes/database.inc");
require_once("includes/database.mysql.inc");
$connect_url = 'mysql://user:pwd@server/database';
$active_db = db_connect($connect_url);
$sql = 'SHOW TABLES';
if ( !( $result = db_query( $sql ) ) ) {
echo '<span >Get SHOW TABLE - SQL Error: ' . $result . '<br>' . "</span>\n";
}
while ( $tables = db_fetch_array($result) ) {
echo $tables[0];
# Loop through all tables in this database
$table = $tables[key($tables)];
if ( !( $result2 = db_query("ALTER TABLE %s COLLATE utf8_general_ci", $table) ) ) {
echo '<span >UTF SET - SQL Error: <br>' . "</span>\n";
break;
}
print "$table changed to UTF-8 successfully.<br>\n";
# Now loop through all the fields within this table
if ( !($result2 = db_query("SHOW COLUMNS FROM %s",$table) ) ) {
echo '<span >Get Table Columns Query - SQL Error: <br>' . "</span>\n";
break;
}
while ( $column = db_fetch_array( $result2 ) )
{
$field_name = $column['Field'];
$field_type = $column['Type'];
# Change text based fields
$skipped_field_types = array('char', 'text', 'enum', 'set');
foreach ( $skipped_field_types as $type )
{
if ( strpos($field_type, $type) !== false )
{
$sql4 = "ALTER TABLE $table CHANGE `$field_name` `$field_name` $field_type CHARACTER SET utf8 COLLATE utf8_bin";
$result4 = db_query($sql4);
echo "---- $field_name changed to UTF-8 successfully.<br>\n";
}
}
}
echo "<hr>\n";
}
?>- Look at the red line in the code in red (5th line). You have to replace that part with your installation-specific information.
- Open the file sites/default/settings.php under the same Drupal root directory. Copy the rest of the line of
$db_url =
and paste it after$connect_url =
in the above code. - Save collate_db.php
- Open a browser window and request the collate_db.php from your browser.
- If everything is fine you would see something similar to this:
access changed to UTF-8 successfully.
---- mask changed to UTF-8 successfully.
---- type changed to UTF-8 successfully.
<--- Lines not shown --->
watchdog changed to UTF-8 successfully.
---- type changed to UTF-8 successfully.
---- message changed to UTF-8 successfully.
---- variables changed to UTF-8 successfully.
---- link changed to UTF-8 successfully.
---- location changed to UTF-8 successfully.
---- referer changed to UTF-8 successfully.
---- hostname changed to UTF-8 successfully.
- Delete collate_db.php for security.
You are done.
[Source: http://www.urbannatives.net/localtreechild/..._ci_and_tabl ]
No comments:
Post a Comment