diff --git a/application/tables/DeploymentLogTable.php b/application/tables/DeploymentLogTable.php index 8aa5d959..1f56715c 100644 --- a/application/tables/DeploymentLogTable.php +++ b/application/tables/DeploymentLogTable.php @@ -57,7 +57,7 @@ class DeploymentLogTable extends QuickTable 'duration' => "l.duration_dump || 'ms'", ); - if ($this->connection->getDbType() === 'pgsql') { + if ($this->connection->isPgsql()) { $columns['checksum'] = "LOWER(ENCODE(c.checksum, 'hex'))"; } diff --git a/application/tables/GeneratedConfigFileTable.php b/application/tables/GeneratedConfigFileTable.php index a5bc4a0d..fc178cee 100644 --- a/application/tables/GeneratedConfigFileTable.php +++ b/application/tables/GeneratedConfigFileTable.php @@ -17,7 +17,7 @@ class GeneratedConfigFileTable extends QuickTable 'config_checksum' => 'LOWER(HEX(cf.config_checksum))', ); - if ($this->connection->getDbType() === 'pgsql') { + if ($this->connection->isPgsql()) { $columns['checksum'] = "LOWER(ENCODE(f.checksum, 'hex'))"; $columns['config_checksum'] = "LOWER(ENCODE(cf.config_checksum, 'hex'))"; } diff --git a/application/tables/IcingaHostTable.php b/application/tables/IcingaHostTable.php index cf523786..59cfb520 100644 --- a/application/tables/IcingaHostTable.php +++ b/application/tables/IcingaHostTable.php @@ -13,7 +13,7 @@ class IcingaHostTable extends IcingaObjectTable public function getColumns() { - if ($this->connection()->getDbType() === 'pgsql') { + if ($this->connection()->isPgsql()) { $parents = "ARRAY_TO_STRING(ARRAY_AGG(ih.object_name ORDER BY hi.weight), ', ')"; } else { $parents = "GROUP_CONCAT(ih.object_name ORDER BY hi.weight SEPARATOR ', ')"; diff --git a/application/tables/IcingaZoneTable.php b/application/tables/IcingaZoneTable.php index 2dc2db19..8f6742c9 100644 --- a/application/tables/IcingaZoneTable.php +++ b/application/tables/IcingaZoneTable.php @@ -12,7 +12,7 @@ class IcingaZoneTable extends IcingaObjectTable public function getColumns() { - if ($this->connection()->getDbType() === 'pgsql') { + if ($this->connection()->isPgsql()) { $endpoints = "ARRAY_TO_STRING(ARRAY_AGG(e.object_name), ', ')"; } else { $endpoints = "GROUP_CONCAT(e.object_name ORDER BY e.object_name SEPARATOR ', ')"; diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php index 090baca0..857cefaf 100644 --- a/library/Director/Data/Db/DbObject.php +++ b/library/Director/Data/Db/DbObject.php @@ -629,7 +629,7 @@ abstract class DbObject unset($properties[$this->autoincKeyName]); } // TODO: Remove this! - if ($this->connection->getDbType() === 'pgsql') { + if ($this->connection->isPgsql()) { foreach ($properties as $key => $value) { if (preg_match('/checksum$/', $key)) { $properties[$key] = Util::pgBinEscape($value); @@ -688,7 +688,7 @@ abstract class DbObject if ($this->insertIntoDb()) { $id = $this->getId(); if ($this->autoincKeyName) { - if ($this->connection->getDbType() === 'pgsql') { + if ($this->connection->isPgsql()) { $this->properties[$this->autoincKeyName] = $this->db->lastInsertId( $table, $this->autoincKeyName diff --git a/library/Director/Db.php b/library/Director/Db.php index 1146531d..c512aeb1 100644 --- a/library/Director/Db.php +++ b/library/Director/Db.php @@ -208,7 +208,7 @@ class Db extends DbConnection public function fetchActivityLogIdByChecksum($checksum) { - if ($this->getDbType() === 'pgsql') { + if ($this->isPgsql()) { $checksum = new Zend_Db_Expr("\\x" . bin2hex($checksum)); } @@ -218,7 +218,7 @@ class Db extends DbConnection public function fetchActivityLogEntry($checksum) { - if ($this->getDbType() === 'pgsql') { + if ($this->isPgsql()) { $checksum = new Zend_Db_Expr("\\x" . bin2hex($checksum)); } @@ -238,7 +238,7 @@ class Db extends DbConnection public function getLastActivityChecksum() { - if ($this->getDbType() === 'pgsql') { + if ($this->isPgsql()) { $select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(ENCODE(checksum, 'hex')) AS checksum" . " FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a" . " UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1"; @@ -419,7 +419,7 @@ class Db extends DbConnection public function getLatestImportedChecksum($source) { - if ($this->getDbType() === 'pgsql') { + if ($this->isPgsql()) { $col = "LOWER(ENCODE(rowset_checksum, 'hex'))"; } else { $col = '(LOWER(HEX(import_run.rowset_checksum)))'; @@ -665,6 +665,11 @@ class Db extends DbConnection return $this->db()->fetchAll($select); } + public function isPgsql() + { + return $this->getDbType() === 'pgsql'; + } + public function getUncollectedDeployments() { $db = $this->db(); diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php index 662bb460..c584129a 100644 --- a/library/Director/IcingaConfig/IcingaConfig.php +++ b/library/Director/IcingaConfig/IcingaConfig.php @@ -186,7 +186,7 @@ class IcingaConfig protected function dbBin($binary) { - if ($this->connection->getDbType() === 'pgsql') { + if ($this->connection->isPgsql()) { return Util::pgBinEscape($binary); } else { return $binary;