Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2267

Přidáno uživatelem Ondřej Fibich před více než 10 roky(ů)

Opravy:
- refs #718: Oprava prasackeho jeffova kodu v My_Controller

Zobrazit rozdíly:

freenetis/branches/1.1/application/libraries/MY_Controller.php
// db schema is not up to date => we must run upgrade
else if (!Version::is_db_up_to_date())
{
$db = Database::instance();
if ($db->query('SHOW VARIABLES LIKE "character_set_database"')->current()->Value != 'utf8' ||
$db->query('SHOW VARIABLES LIKE "collation_database"')->current()->Value != 'utf8_czech_ci')
// change database encoding if incorect
try
{
try
$db = Database::instance();
/**
* @todo in the future the collate should be used according
* to language system settings
*/
if ($db->get_variable_value('character_set_database') != 'utf8' ||
$db->get_variable_value('collation_database') != 'utf8_czech_ci')
{
$db->query('ALTER DATABASE `'.Settings::get('db_name').'` DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci');
$db->alter_db_character_set(
Config::get('db_name'), 'utf8', 'utf8_czech_ci'
);
}
catch (Exception $e)
{
Log::add_exception($e);
self::showbox(__('Cannot set database character set to UTF8'), self::ICON_ERROR);
}
}
catch (Exception $e)
{
Log::add_exception($e);
$m = __('Cannot set database character set to UTF8');
self::showbox($m, self::ICON_ERROR);
}
// try to open mutex file
if (($f = @fopen(server::base_dir().'/upload/mutex', 'w')) === FALSE)
freenetis/branches/1.1/system/libraries/Database.php
{
$this->config['benchmark'] = ($is_on === TRUE);
}
/**
* Gets value of database variable. If variable not present in the database
* NULL is returned.
*
* @author Ondřej Fibich
* @param string $name Variable name
* @return string|null
*/
public function get_variable_value($name)
{
$result = $this->query("SHOW VARIABLES LIKE ?", $name);
if ($result->count() == 1)
{
$o = $result->current();
if (isset($o->Value))
{
return $o->Value;
}
}
return NULL;
}
/**
* Alterch character set amd collate of database to given values.
*
* @author Ondřej Fibich
* @param string $db_name Database name
* @param string $set Character set name
* @param string $collate Collate name
*/
public function alter_db_character_set($db_name, $set, $collate)
{
$db_name = $this->escape_table($db_name);
$this->query("ALTER DATABASE $db_name DEFAULT CHARACTER SET ? COLLATE ?", array
(
$set, $collate
));
}
} // End Database Class

Také k dispozici: Unified diff