diff --git a/Sources/Db/APIs/MySQL.php b/Sources/Db/APIs/MySQL.php index 60b56f089d..d3f7d473a0 100644 --- a/Sources/Db/APIs/MySQL.php +++ b/Sources/Db/APIs/MySQL.php @@ -1984,24 +1984,23 @@ protected function __construct(array $options = []) $this->prefixReservedTables(); } - // For backward compatibility. - if (!is_object(self::$db_connection)) { - self::$db_connection = $this->connection; - } - // At this point, if we don't have a connection, nothing else can be done. if (empty($this->connection)) { return; } + // For backward compatibility. + if (!is_object(self::$db_connection)) { + self::$db_connection = $this->connection; + } + $this->get_version(); $this->supports_pcre = version_compare($this->version, strpos($this->version, 'MariaDB') !== false ? '10.0.5' : '8.0.4', '>='); // Ensure database has UTF-8 as its default input charset. $this->query( '', - ' - SET NAMES {string:db_character_set}', + 'SET NAMES {string:db_character_set}', [ 'db_character_set' => $this->character_set, ], diff --git a/Sources/Db/APIs/PostgreSQL.php b/Sources/Db/APIs/PostgreSQL.php index cf76afa618..c668f5d4fa 100644 --- a/Sources/Db/APIs/PostgreSQL.php +++ b/Sources/Db/APIs/PostgreSQL.php @@ -2112,16 +2112,16 @@ protected function __construct(array $options = []) ErrorHandler::displayDbError(); } - // For backward compatibility. - if (!is_object(self::$db_connection)) { - self::$db_connection = $this->connection; - } - // At this point, if we don't have a connection, nothing else can be done. if (empty($this->connection)) { return; } + // For backward compatibility. + if (!is_object(self::$db_connection)) { + self::$db_connection = $this->connection; + } + // Ensure database has UTF-8 as its default input charset. $this->query( '',