/**
     * Creates an object from the database.
     * Maybe we could have a factory for this later...let's
     * keep it simple for now
     * 
     * @return WfsConfiguration
     * @param $id Integer
     */
    public static function createFromDb($id)
    {
        if (!is_numeric($id)) {
            return null;
        }
        $wfsConf = new WfsConfiguration();
        $wfsConf->id = intval($id);
        if (!$wfsConf->accessAllowed()) {
            return null;
        }
        $sql = <<<SQL
SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id 
WHERE wfs_conf.wfs_conf_id = \$1 LIMIT 1
SQL;
        $v = array($wfsConf->id);
        $t = array("i");
        $res = db_prep_query($sql, $v, $t);
        $row = db_fetch_array($res);
        $wfsConf->abstr = $row["wfs_conf_abstract"];
        $wfsConf->description = $row["wfs_conf_description"];
        $wfsConf->label = $row["g_label"];
        $wfsConf->labelId = $row["g_label_id"];
        $wfsConf->style = $row["g_style"];
        $wfsConf->button = $row["g_button"];
        $wfsConf->buttonId = $row["g_button_id"];
        $wfsConf->buffer = $row["g_buffer"];
        $wfsConf->resStyle = $row["g_res_style"];
        $wfsConf->wfsId = intval($row["fkey_wfs_id"]);
        $wfsConf->type = intval($row["wfs_conf_type"]);
        $wfsConf->featureTypeId = intval($row["fkey_featuretype_id"]);
        $sql = <<<SQL
SELECT featuretype_name FROM wfs_featuretype WHERE featuretype_id = \$1 LIMIT 1
SQL;
        $v = array($wfsConf->featureTypeId);
        $t = array("i");
        $res = db_prep_query($sql, $v, $t);
        $row = db_fetch_array($res);
        $wfsConf->featureTypeName = $row["featuretype_name"];
        $sql = <<<SQL
SELECT * FROM wfs_conf_element JOIN wfs_element 
ON wfs_conf_element.f_id = wfs_element.element_id 
WHERE wfs_conf_element.fkey_wfs_conf_id = \$1 
ORDER BY wfs_conf_element.f_id
SQL;
        $v = array($wfsConf->id);
        $t = array('i');
        $res = db_prep_query($sql, $v, $t);
        while ($row = db_fetch_array($res)) {
            $element = new WfsConfigurationElement();
            $element->id = intval($row["element_id"]);
            $element->name = $row["element_name"];
            $element->type = $row["element_type"];
            $element->search = intval($row["f_search"]);
            $element->pos = intval($row["f_pos"]);
            $element->edit = intval($row["f_edit"]);
            $element->styleId = $row["f_style_id"];
            $element->toUpper = intval($row["f_toupper"]);
            $element->label = $row["f_label"];
            $element->labelId = $row["f_label_id"];
            $element->geom = intval($row["f_geom"]);
            $element->show = intval($row["f_show"]);
            $element->mandatory = intval($row["f_mandatory"]);
            $element->respos = intval($row["f_respos"]);
            $element->minInput = intval($row["f_min_input"]);
            //			$element->formElementHtmlTemplate = $row["f_html_template"];
            $element->formElementHtml = $row["f_form_element_html"];
            $element->authVarname = stripslashes($row["f_auth_varname"]);
            $element->detailPos = intval($row["f_detailpos"]);
            $element->operator = $row["f_operator"];
            $element->showDetail = intval($row["f_show_detail"]);
            $element->helptext = $row["f_helptext"];
            $element->category = $row["f_category_name"];
            $wfsConf->elementArray[] = $element;
        }
        $wfsConf->id = intval($id);
        return $wfsConf;
    }