public function postConnect($link)
{
if (!defined('PMA_MYSQL_INT_VERSION')) {
$version = $this->fetchSingleRow('SELECT @@version, @@version_comment', 'ASSOC', $link);
if ($version) {
$match = explode('.', $version['@@version']);
define('PMA_MYSQL_MAJOR_VERSION', (int) $match[0]);
define('PMA_MYSQL_INT_VERSION', (int) sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
define('PMA_MYSQL_STR_VERSION', $version['@@version']);
define('PMA_MYSQL_VERSION_COMMENT', $version['@@version_comment']);
} else {
define('PMA_MYSQL_INT_VERSION', 50501);
define('PMA_MYSQL_MAJOR_VERSION', 5);
define('PMA_MYSQL_STR_VERSION', '5.05.01');
define('PMA_MYSQL_VERSION_COMMENT', '');
}
/* Detect MariaDB */
if (mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') !== false) {
define('PMA_MARIADB', true);
} else {
define('PMA_MARIADB', false);
}
}
if (PMA_MYSQL_INT_VERSION > 50503) {
$default_charset = 'utf8mb4';
$default_collation = 'utf8mb4_general_ci';
} else {
$default_charset = 'utf8';
$default_collation = 'utf8_general_ci';
}
if (!empty($GLOBALS['collation_connection'])) {
$this->query("SET CHARACTER SET '{$default_charset}';", $link, self::QUERY_STORE);
/* Automatically adjust collation to mb4 variant */
if ($default_charset == 'utf8mb4' && strncmp('utf8_', $GLOBALS['collation_connection'], 5) == 0) {
$GLOBALS['collation_connection'] = 'utf8mb4_' . substr($GLOBALS['collation_connection'], 5);
}
$result = $this->tryQuery("SET collation_connection = '" . $this->escapeString($GLOBALS['collation_connection'], $link) . "';", $link, self::QUERY_STORE);
if ($result === false) {
trigger_error(__('Failed to set configured collation connection!'), E_USER_WARNING);
$this->query("SET collation_connection = '" . $this->escapeString($GLOBALS['collation_connection'], $link) . "';", $link, self::QUERY_STORE);
}
} else {
$this->query("SET NAMES '{$default_charset}' COLLATE '{$default_collation}';", $link, self::QUERY_STORE);
}
/* Locale for messages */
$locale = LanguageManager::getInstance()->getCurrentLanguage()->getMySQLLocale();
if (!empty($locale)) {
$this->query("SET lc_messages = '" . $locale . "';", $link, self::QUERY_STORE);
}
}