[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaConfig: add static exists() helper

git at icinga.org git at icinga.org
Thu Jun 16 16:13:49 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 734c7c7b02dbe08dac1e6cc2f93948b12f473faf
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=734c7c7b02dbe08dac1e6cc2f93948b12f473faf

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Jun 16 15:48:54 2016 +0200

IcingaConfig: add static exists() helper

---

 library/Director/IcingaConfig/IcingaConfig.php |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php
index be31ab2..1e3dfa7 100644
--- a/library/Director/IcingaConfig/IcingaConfig.php
+++ b/library/Director/IcingaConfig/IcingaConfig.php
@@ -132,6 +132,20 @@ class IcingaConfig
         return $config;
     }
 
+    public static function exists($checksum, Db $connection)
+    {
+        $db = $connnection->getDbAdapter();
+        $query = $db->select()->from(
+            array('c' => self::$table),
+            array('checksum' => $connection->dbHexFunc('c.checksum'))
+        )->where(
+            'checksum = ?',
+            $connection->quoteBinary(Util::hex2binary($checksum))
+        );
+
+        return $db->fetchOne($query) === $checksum;
+    }
+
     public static function loadByActivityChecksum($checksum, Db $connection)
     {
         $db = $connection->getDbAdapter();



More information about the icinga-checkins mailing list