protected function saveSettingsData(&$data)
    {
        $update_string = "";
        
        foreach ($this->settings_fields as $field => $type) {
            if ($field == $this->user_id_field) {
                continue;
            }
            
            $value = $this->dbworker->escape(checkempty($data[$field]));
            
            if (empty($value) && (string)$value != "0") {
                $update_string .= $field . " = NULL,\n";
            } else switch ($type) {
                case DBWorker::DB_NUMBER:
                    $update_string .= $field . " = " . $value . ",\n";
                    break;
                
                case DBWorker::DB_DATETIME:
                    $update_string .= $field . " = '" . $this->dbworker->format_datetime($value) . "',\n";
                    break;
                
                case DBWorker::DB_DATE:
                    $update_string .= $field . " = '" . $this->dbworker->format_date($value) . "',\n";
                    break;
                
                default:
                    $update_string .= $field . " = '" . $value . "',\n";
            }
        }
        
        $query = "UPDATE " . $this->user_table . " SET\n";
        $query .= trim($update_string, ",\n") . "\n";
        $query .= $this->getWhereClause();
        
        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;
    }