IcingaConfig: allow to loadByActivityChecksum

This commit is contained in:
Thomas Gelf 2016-05-25 11:53:01 +02:00
parent 0199af7dcb
commit c205d9f80d
1 changed files with 18 additions and 0 deletions

View File

@ -132,6 +132,24 @@ class IcingaConfig
return $config;
}
public static function loadByActivityChecksum($checksum, Db $connection)
{
$db = $connection->getDbAdapter();
$query = $db->select()->from(
array('c' => self::$table),
array('checksum' => 'c.checksum')
)->join(
array('l' => 'director_activity_log'),
'l.checksum = c.last_activity_checksum',
array()
)->where(
'last_activity_checksum = ?',
$connection->quoteBinary(Util::hex2binary($checksum))
)->order('l.id DESC')->limit(1);
return self::load($db->fetchOne($query), $connection);
}
public static function generate(Db $connection)
{
$config = new static($connection);