aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2007-10-09 01:43:29 +0000
committerrvelices <rv-github@modusoptimus.com>2007-10-09 01:43:29 +0000
commite9becfa669f9d7e64440992daeaf937388d26686 (patch)
treed5c8144c4c7ece7d71b2d9281b7c9f3c5cac2772 /admin/include
parent98b07a4a7fa1baff52800f70066f311768904430 (diff)
- PWG_CHARSET, DB_CHARSET and DB_COLLATE... utf-8 ready
git-svn-id: http://piwigo.org/svn/trunk@2127 68402e56-0260-453c-a942-63ccdbb3a9ee
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