mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Implement more accurate management of the current charset
This commit is contained in:
parent
ecac6d1490
commit
d9a9cfe21b
4 changed files with 25 additions and 9 deletions
|
|
@ -19,6 +19,7 @@ class DBMysql extends DB
|
|||
*/
|
||||
var $prefix = 'xe_'; // / <
|
||||
var $comment_syntax = '/* %s */';
|
||||
var $charset = null;
|
||||
|
||||
/**
|
||||
* Column type used in MySQL
|
||||
|
|
@ -83,7 +84,14 @@ class DBMysql extends DB
|
|||
}
|
||||
|
||||
// Set charset
|
||||
$charset = isset($connection["db_charset"]) ? $connection["db_charset"] : 'utf8';
|
||||
if(isset($connection["db_charset"]))
|
||||
{
|
||||
$charset = $this->charset = $connection["db_charset"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$charset = 'utf8';
|
||||
}
|
||||
$this->_query("SET NAMES $charset", $connection);
|
||||
|
||||
// select db
|
||||
|
|
@ -998,13 +1006,12 @@ class DBMysql extends DB
|
|||
*/
|
||||
function getBestSupportedCharset()
|
||||
{
|
||||
static $cache = null;
|
||||
if ($cache !== null)
|
||||
if ($this->charset !== null)
|
||||
{
|
||||
return $cache;
|
||||
return $this->charset;
|
||||
}
|
||||
|
||||
if($output = $this->_fetch($this->_query("SHOW CHARACTER SET LIKE 'utf8mb4%'")))
|
||||
if($output = $this->_fetch($this->_query("SHOW CHARACTER SET LIKE 'utf8%'")))
|
||||
{
|
||||
$mb4_support = false;
|
||||
foreach($output as $row)
|
||||
|
|
@ -1014,11 +1021,11 @@ class DBMysql extends DB
|
|||
$mb4_support = true;
|
||||
}
|
||||
}
|
||||
return $cache = ($mb4_support ? 'utf8' : 'utf8');
|
||||
return $this->charset = ($mb4_support ? 'utf8mb4' : 'utf8');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $cache = 'utf8';
|
||||
return $this->charset = 'utf8';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,14 @@ class DBMysqli extends DBMysql
|
|||
$this->setError($error, mysqli_connect_error());
|
||||
return;
|
||||
}
|
||||
$charset = isset($connection["db_charset"]) ? $connection["db_charset"] : 'utf8';
|
||||
if(isset($connection["db_charset"]))
|
||||
{
|
||||
$charset = $this->charset = $connection["db_charset"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$charset = 'utf8';
|
||||
}
|
||||
mysqli_set_charset($result, $charset);
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue