Skip to content

Commit 4c0016d

Browse files
Assign mySQLInitCommand constant directly
1 parent d5c87b1 commit 4c0016d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/Icinga/Common/Database.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ protected function getDb(): Connection
3838
// In PHP 8.5+, driver specific constants of the PDO class are deprecated,
3939
// but the replacements are ony available since php 8.4
4040
if (version_compare(PHP_VERSION, '8.4.0', '<')) {
41-
$mysqlConstantPrefix = 'PDO::MYSQL_ATTR_';
41+
$mysqlInitCommand = PDO::MYSQL_ATTR_INIT_COMMAND;
4242
} else {
43-
$mysqlConstantPrefix = 'Pdo\Mysql::ATTR_';
43+
$mysqlInitCommand = Pdo\Mysql::ATTR_INIT_COMMAND;
4444
}
4545

4646
$config->options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ];
4747
if ($config->db === 'mysql') {
48-
$config->options[constant($mysqlConstantPrefix . 'INIT_COMMAND')]
48+
$config->options[$mysqlInitCommand]
4949
= "SET SESSION SQL_MODE='STRICT_TRANS_TABLES"
5050
. ",NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'";
5151
}

0 commit comments

Comments
 (0)