<?php

  // include base peer class
  require_once 'om/BaseNagiosHostPeer.php';

  // include object class
  include_once 'NagiosHost.php';


/**
 * Skeleton subclass for performing query and update operations on the 'nagios_host' table.
 *
 * Nagios Host
 *
 * This class was autogenerated by Propel on:
 *
 * Thu Dec 13 21:25:24 2007
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    
 */
class NagiosHostPeer extends BaseNagiosHostPeer {

	public function getByName($name) {
		$c = new Criteria();
		$c->add(NagiosHostPeer::NAME, $name);
		$c->setIgnoreCase(true);
		$host = NagiosHostPeer::doSelectOne($c);
		if(!$host) {
			return false;
		}
		return $host;
	}

	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";
		$stmt = $con->prepare($sql);
		$stmt->execute();
		$hosts = NagiosHostPeer::populateObjects($stmt);
		return $hosts;
	}

} // NagiosHostPeer
