protected function saveXMLtoDB(&$data)
    {
        $this->validateParameters();

        $xmldoc = new \DOMDocument("1.0", "UTF-8");
        $xmldoc->formatOutput = true;
        
        $root = $xmldoc->createElement("array");
        $root = $xmldoc->appendChild($root);
        
        array_to_dom($root, $data);
        
        $xml = $xmldoc->saveXML();
        
        // check existance
        
        $query = "SELECT 1 FROM " . $this->settings_table;
        
        if (!$this->dbworker->execute_query($query)) {
            throw new \Exception($this->dbworker->get_last_error() . "\n\n" . $this->dbworker->get_last_query(), "system_error");
        }
        
        $must_insert = true;
        
        if ($this->dbworker->fetch_row()) {
            $must_insert = false;
        }
        
        $this->dbworker->free_result();
        
        $xml = $this->dbworker->escape($xml);
        
        if ($must_insert) {
            $query = "INSERT INTO " . $this->settings_table . "(" . $this->settings_column . ")\n";
            $query .= "VALUES ('$xml')";
        } else {
            $query = "UPDATE " . $this->settings_table . " SET " . $this->settings_column . " = '$xml'";
        }
        
        if (!$this->dbworker->execute_query($query)) {
            throw new \Exception($this->dbworker->get_last_error() . "\n\n" . $this->dbworker->get_last_query(), "system_error");
        }
        
        return true;
    }