public function storeToDb(IcingaObject $object) { $db = $object->getDb(); $table = $object->getVarsTableName(); $foreignColumn = $object->getVarsIdColumn(); $foreignId = $object->id; foreach ($this->vars as $var) { if ($var->isNew()) { $db->insert($table, array($foreignColumn => $foreignId, 'varname' => $var->getKey(), 'varvalue' => $var->getDbValue(), 'format' => $var->getDbFormat())); continue; } $where = $db->quoteInto(sprintf('%s = ?', $foreignColumn), (int) $foreignId) . $db->quoteInto(' AND varname = ?', $var->getKey()); if ($var->hasBeenDeleted()) { $db->delete($table, $where); } elseif ($var->hasBeenModified()) { $db->update($table, array('varvalue' => $var->getDbValue(), 'format' => $var->getDbFormat()), $where); } } $this->setUnmodified(); }