[Mapbender-commits] r6240 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Jun 2 06:14:18 EDT 2010
Author: verenadiewald
Date: 2010-06-02 06:14:18 -0400 (Wed, 02 Jun 2010)
New Revision: 6240
Modified:
trunk/mapbender/http/classes/class_wfsToDb.php
Log:
update keywords for featuretypes
Modified: trunk/mapbender/http/classes/class_wfsToDb.php
===================================================================
--- trunk/mapbender/http/classes/class_wfsToDb.php 2010-06-02 09:52:41 UTC (rev 6239)
+++ trunk/mapbender/http/classes/class_wfsToDb.php 2010-06-02 10:14:18 UTC (rev 6240)
@@ -596,6 +596,61 @@
}
}
+
+ // update keywords
+ $sql = "DELETE FROM wfs_featuretype_keyword WHERE fkey_featuretype_id = $1";
+ $v = array($aWfsFeatureType->id);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+
+ $k = $aWfsFeatureType->featuretype_keyword;
+// var_dump($k);
+ for($j=0; $j<count($k); $j++){
+ $keyword_id = "";
+
+ while ($keyword_id == "") {
+ $sql = "SELECT keyword_id FROM keyword WHERE UPPER(keyword) = UPPER($1)";
+ $v = array($k[$j]);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ $row = db_fetch_array($res);
+ //print_r($row);
+ if ($row) {
+ $keyword_id = $row["keyword_id"];
+ }
+ else {
+ $sql_insertKeyword = "INSERT INTO keyword (keyword)";
+ $sql_insertKeyword .= "VALUES ($1)";
+ $v1 = array($k[$j]);
+ $t1 = array('s');
+ $res_insertKeyword = db_prep_query($sql_insertKeyword,$v1,$t1);
+ if(!$res_insertKeyword){
+ $e = new mb_exception("Error while inserting keywords into the database.");
+ return false;
+ }
+ }
+ }
+
+ // check if featuretype/keyword combination already exists
+ $sql_fiKeywordExists = "SELECT * FROM wfs_featuretype_keyword WHERE fkey_featuretype_id = $1 AND fkey_keyword_id = $2";
+ $v = array($aWfsFeatureType->id, $keyword_id);
+ $t = array('i', 'i');
+ $res_fiKeywordExists = db_prep_query($sql_fiKeywordExists, $v, $t);
+ $row = db_fetch_array($res_fiKeywordExists);
+ //print_r($row);
+ if (!$row) {
+ $sql1 = "INSERT INTO wfs_featuretype_keyword (fkey_keyword_id,fkey_featuretype_id)";
+ $sql1 .= "VALUES ($1,$2)";
+ $v1 = array($keyword_id,$aWfsFeatureType->id);
+ $t1 = array('i','i');
+ $res1 = db_prep_query($sql1,$v1,$t1);
+ if(!$res1){
+ $e = new mb_exception("Error while inserting wfs_featuretype_keywords into the database.");
+ return false;
+ }
+ }
+ }
+
return true;
}
More information about the Mapbender_commits
mailing list