aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include
diff options
context:
space:
mode:
Diffstat (limited to 'admin/include')
-rw-r--r--admin/include/functions.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 23cf41180..b22074d79 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1989,4 +1989,34 @@ UPDATE '.USER_CACHE_TABLE.'
pwg_query($query);
trigger_action('invalidate_user_cache');
}
+
+/**
+ * adds the caracter set to a create table sql query.
+ * all CREATE TABLE queries must call this function
+ * @param string query - the sql query
+ */
+function create_table_add_character_set($query)
+{
+ defined('DB_CHARSET') or die('create_table_add_character_set DB_CHARSET undefined');
+ if ('DB_CHARSET'!='')
+ {
+ if ( version_compare(mysql_get_server_info(), '4.1.0', '<') )
+ {
+ return $query;
+ }
+ $charset_collate = " DEFAULT CHARACTER SET ".DB_CHARSET;
+ if ('DB_COLLATE'!='')
+ {
+ $charset_collate .= " COLLATE ".DB_COLLATE;
+ }
+ $query=trim($query);
+ $query=trim($query, ';');
+ if (preg_match('/^CREATE\s+TABLE/i',$query))
+ {
+ $query.=$charset_collate;
+ }
+ $query .= ';';
+ }
+ return $query;
+}
?> \ No newline at end of file