From b8b77332c45f7011fee081ecd34732465adf9257 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jul 2021 08:36:49 +0200 Subject: [PATCH] Database: Only use `PDO::MYSQL_ATTR_INIT_COMMAND` for mysql connections fixes #4441 --- library/Icinga/Common/Database.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Common/Database.php b/library/Icinga/Common/Database.php index 4344f189e..32d21153f 100644 --- a/library/Icinga/Common/Database.php +++ b/library/Icinga/Common/Database.php @@ -32,11 +32,11 @@ trait Database IcingaConfig::app()->get('global', 'config_resource') )); - $config->options = [ - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, - PDO::MYSQL_ATTR_INIT_COMMAND => "SET SESSION SQL_MODE='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE" - . ",ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'" - ]; + $config->options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ]; + if ($config->db === 'mysql') { + $config->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" + . ",NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'"; + } return new Connection($config); }