Changeset 2127 for trunk/admin/include


Ignore:
Timestamp:
Oct 9, 2007, 3:43:29 AM (17 years ago)
Author:
rvelices
Message:
  • PWG_CHARSET, DB_CHARSET and DB_COLLATE... utf-8 ready
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r2095 r2127  
    19901990  trigger_action('invalidate_user_cache');
    19911991}
     1992
     1993/**
     1994 * adds the caracter set to a create table sql query.
     1995 * all CREATE TABLE queries must call this function
     1996 * @param string query - the sql query
     1997 */
     1998function create_table_add_character_set($query)
     1999{
     2000  defined('DB_CHARSET') or die('create_table_add_character_set DB_CHARSET undefined');
     2001  if ('DB_CHARSET'!='')
     2002  {
     2003    if ( version_compare(mysql_get_server_info(), '4.1.0', '<') )
     2004    {
     2005      return $query;
     2006    }
     2007    $charset_collate = " DEFAULT CHARACTER SET ".DB_CHARSET;
     2008    if ('DB_COLLATE'!='')
     2009    {
     2010      $charset_collate .= " COLLATE ".DB_COLLATE;
     2011    }
     2012    $query=trim($query);
     2013    $query=trim($query, ';');
     2014    if (preg_match('/^CREATE\s+TABLE/i',$query))
     2015    {
     2016      $query.=$charset_collate;
     2017    }
     2018    $query .= ';';
     2019  }
     2020  return $query;
     2021}
    19922022?>
Note: See TracChangeset for help on using the changeset viewer.