Esempio n. 1
0
 /**
  * Create association between Os and OsGroup
  */
 public function assignOsToOsGroup(Os &$os, OsGroup &$osGroup)
 {
     if ($os == null || $os->getId() == -1 || $osGroup == null) {
         Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__);
         throw new Exception("Os or OsGroup object is not valid or Os.id|OsGroup.id is not set");
     }
     Utils::log(LOG_DEBUG, "Assigning the os to the os group [os=" . $os->getName() . ",osGroupName=" . $osGroup->getName() . "]", __FILE__, __LINE__);
     # Check if the tag already exists
     $isAssigned = $this->getPakiti()->getManager("DbManager")->queryToSingleValue("select 1 from OsOsGroup where\n    \t \t\tosId=" . $this->getPakiti()->getManager("DbManager")->escape($os->getId()) . "");
     if ($isAssigned == null) {
         # Association between os and osGroup doesn't exist, so create it
         $this->getPakiti()->getManager("DbManager")->query("insert into OsOsGroup set\n          osId=" . $this->getPakiti()->getManager("DbManager")->escape($os->getId()) . ",\n    \t \t\tosGroupId=" . $this->getPakiti()->getManager("DbManager")->escape($osGroup->getId()));
     } else {
         # Update
         $this->getPakiti()->getManager("DbManager")->query("update OsOsGroup set\n          osId=" . $this->getPakiti()->getManager("DbManager")->escape($os->getId()) . ",\n    \t \t\tosGroupId=" . $this->getPakiti()->getManager("DbManager")->escape($osGroup->getId()) . " where\n    \t \t\tosId=" . $this->getPakiti()->getManager("DbManager")->escape($os->getId()) . "");
     }
 }
Esempio n. 2
0
 public function update(OsGroup &$osGroup)
 {
     $this->db->query("update OsGroup set\n      \tname='" . $this->db->escape($osGroup->getName()) . "\n      where id=" . $osGroup->getId());
 }