* [refac] Improve charset encoding validation in dbh constructor.
This commit is contained in:
@@ -136,9 +136,11 @@ class dbh
|
||||
/* Mysql driver include mysql and oceanbase. */
|
||||
if($driver == 'mysql')
|
||||
{
|
||||
$collation = $dbConfig->collation ?? 'utf8mb4_general_ci';
|
||||
$queries[] = "SET NAMES {$dbConfig->encoding}";
|
||||
$queries[] = "SET COLLATION_CONNECTION = '{$collation}'";
|
||||
$encoding = strtolower($dbConfig->encoding ?? 'utf8mb4');
|
||||
$collation = strtolower($dbConfig->collation ?? 'utf8mb4_general_ci');
|
||||
if($encoding !== 'utf8mb4') $encoding = 'utf8mb4';
|
||||
if(strpos($collation, $encoding) !== 0) $collation = 'utf8mb4_general_ci';
|
||||
$queries[] = "SET NAMES {$encoding} COLLATE '{$collation}'";
|
||||
if(isset($dbConfig->strictMode) && empty($dbConfig->strictMode)) $queries[] = "SET @@sql_mode= ''";
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user