From c2582b8d0b56d22ee34e263e397570afc350f29a Mon Sep 17 00:00:00 2001 From: IPv777 <19636346+IPv777@users.noreply.github.com> Date: Wed, 5 Feb 2020 12:05:36 +0100 Subject: [PATCH] Creation of function getById --- classes/NagiosHostPeer.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/classes/NagiosHostPeer.php b/classes/NagiosHostPeer.php index 62f9864..e8542c0 100644 --- a/classes/NagiosHostPeer.php +++ b/classes/NagiosHostPeer.php @@ -26,6 +26,17 @@ static public function getByName($name) { return $host; } + static public function getById($id) { + $c = new Criteria(); + $c->add(NagiosHostPeer::ID, $id); + //$c->setIgnoreCase(true); + $host = NagiosHostPeer::doSelectOne($c); + if(!$host) + return false; + + return $host; + } + static public function getTopLevelHosts() { $con = Propel::getConnection(BaseNagiosHostPeer::DATABASE_NAME); $sql = "SELECT * from nagios_host WHERE (select count(*) FROM nagios_host_parent WHERE nagios_host_parent.child_host = nagios_host.id) = 0 ORDER BY nagios_host.name";