Skip to content

Commit

Permalink
Fix for collation issues, another small fix for time-adjust issues
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/stable_plus@3347 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Oct 7, 2007
1 parent 75a6d98 commit 8890c51
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
2 changes: 1 addition & 1 deletion admin/install/createdb.php
Expand Up @@ -28,7 +28,7 @@
// In Step2 fill the database with data
if (returnglobal('createdbstep2')==$clang->gT("Populate Database"))
{
if ($databasetype=='mysql') {@$connect->Execute("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;");} //Set the collation also for manually created DBs
if ($databasetype=='mysql') {@$connect->Execute("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");} //Set the collation also for manually created DBs
if (modify_database(dirname(__FILE__).'/create-'.$databasetype.'.sql'))
{
echo sprintf($clang->gT("Database `%s` has been successfully populated."),$dbname)."</font></strong></font><br /><br />\n";
Expand Down
48 changes: 48 additions & 0 deletions admin/install/upgrade-mysql.php
Expand Up @@ -87,7 +87,55 @@ function db_upgrade($oldversion) {
modify_database("","update `prefix_settings_global` set `stg_value`='112' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}

if ($oldversion < 113) {
//Fixes the collation for the complete DB, tables and columns
fix_mysql_collation();
modify_database("","update `prefix_settings_global` set `stg_value`='113' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}


return true;
}


function fix_mysql_collation()
{
global $connect, $modifyoutput;
$sql = 'SHOW TABLES';
$result = db_execute_num($sql);
if (!$result) {
$modifyoutput .= 'SHOW TABLE - SQL Error';
}

while ( $tables = $result->FetchRow() ) {
// Loop through all tables in this database
$table = $tables[0];

modify_database("","ALTER TABLE $table COLLATE utf8_unicode_ci");
echo $modifyoutput; flush();

# Now loop through all the fields within this table
$result2 = db_execute_assoc("SHOW COLUMNS FROM ".$table);

while ( $column = $result2->FetchRow())
{
$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 )
{
modify_database("","ALTER TABLE $table CHANGE `$field_name` `$field_name` $field_type CHARACTER SET utf8 COLLATE utf8_unicode_ci");
echo $modifyoutput; flush();
}
}
}
}
}


?>
4 changes: 4 additions & 0 deletions admin/install/upgrade-odbc_mssql.php
Expand Up @@ -85,6 +85,10 @@ function db_upgrade($oldversion) {
modify_database("","ALTER TABLE `prefix_users` ALTER COLUMN `users_name` VARCHAR( 64 ) NOT NULL"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='112' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 113) {
//No action needed
modify_database("","update `prefix_settings_global` set `stg_value`='112' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}


return true;
Expand Down
4 changes: 2 additions & 2 deletions common.php
Expand Up @@ -14,8 +14,8 @@

//Ensure script is not run directly, avoid path disclosure
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
$versionnumber = "1.52";
$dbversionnumber = 112;
$versionnumber = "1.52+";
$dbversionnumber = 113;



Expand Down
2 changes: 1 addition & 1 deletion save.php
Expand Up @@ -301,7 +301,7 @@ function createinsertquery()
// Performance Improvement : 31%
// Optimized By : swales

global $thissurvey;
global $thissurvey,$timeadjust;
global $deletenonvalues, $thistpl;
global $surveyid, $connect, $clang;
$fieldmap=createFieldMap($surveyid); //Creates a list of the legitimate questions for this survey
Expand Down

0 comments on commit 8890c51

Please sign in to comment.