Exemple #1
0
 public function create(Host &$host)
 {
     if ($host == null) {
         Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__);
         throw new Exception("Host object is not valid");
     }
     $this->db->query("insert into Host set\n      \thostname='" . $this->db->escape($host->getHostname()) . "',\n      \tip='" . $this->db->escape($host->getIp()) . "',\n      \treporterIp='" . $this->db->escape($host->getReporterIp()) . "',\n      \treporterHostname='" . $this->db->escape($host->getReporterHostname()) . "',\n      \tkernel='" . $this->db->escape($host->getKernel()) . "',\n      \tosId=" . $this->db->escape($host->getOsId()) . ",\n      \tarchId=" . $this->db->escape($host->getArchId()) . ",\n      \tdomainId=" . $this->db->escape($host->getDomainId()) . ",\n      \tlastReportId=" . ($host->getLastReportId() == -1 ? "NULL" : $this->db->escape($host->getLastReportId())) . ",\n      \ttype='" . $this->db->escape($host->getType()) . "',\n        ownRepositoriesDef=" . $this->db->escape($host->getOwnRepositoriesDef()));
     # Set the newly assigned id
     $host->setId($this->db->getLastInsertedId());
     Utils::log(LOG_DEBUG, "Host created", __FILE__, __LINE__);
 }