/**
  * Updates an existing WFS in the database.
  * 
  * @return Boolean
  * @param $aWfs Wfs
  */
 public static function update($aWfs)
 {
     db_begin();
     // update WFS
     $sql = "UPDATE wfs SET wfs_version = \$1, wfs_name = \$2, wfs_title = \$3, ";
     $sql .= "wfs_abstract = \$4, wfs_getcapabilities = \$5, wfs_getcapabilities_doc = \$6, ";
     $sql .= "wfs_upload_url = \$7, wfs_describefeaturetype = \$8, wfs_getfeature = \$9, ";
     $sql .= "wfs_transaction = \$10, fees = \$11, accessconstraints = \$12, ";
     $sql .= "individualname = \$13, positionname = \$14, providername = \$15, ";
     $sql .= "city = \$16, deliverypoint = \$17, administrativearea = \$18, ";
     $sql .= "postalcode = \$19, voice = \$20, facsimile = \$21, ";
     $sql .= "electronicmailaddress = \$22, country = \$23, ";
     $sql .= "wfs_timestamp = \$24, wfs_network_access = \$25, fkey_mb_group_id = \$26 ";
     $sql .= "WHERE wfs_id = \$27";
     $v = array($aWfs->getVersion(), $aWfs->name, $aWfs->title, $aWfs->summary, $aWfs->getCapabilities, $aWfs->getCapabilitiesDoc, $aWfs->uploadUrl, $aWfs->describeFeatureType, $aWfs->getFeature, $aWfs->transaction, $aWfs->fees, $aWfs->accessconstraints, $aWfs->individualName, $aWfs->positionName, $aWfs->providerName, $aWfs->city, $aWfs->deliveryPoint, $aWfs->administrativeArea, $aWfs->postalCode, $aWfs->voice, $aWfs->facsimile, $aWfs->electronicMailAddress, $aWfs->country, strtotime("now"), $aWfs->network_access, $aWfs->fkey_mb_group_id, $aWfs->id);
     $t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 'i', 'i', 'i');
     $e = new mb_exception("UPDATING WFS " . $aWfs->id);
     $res = db_prep_query($sql, $v, $t);
     if (!$res) {
         $e = new mb_exception("Error while updating WFS in database.");
         db_rollback();
         return false;
     }
     # delete and refill wfs_termsofuse
     $sql = "DELETE FROM wfs_termsofuse WHERE fkey_wfs_id = \$1 ";
     $v = array($aWfs->id);
     $t = array('i');
     $res = db_prep_query($sql, $v, $t);
     if (!$res) {
         db_rollback();
     }
     WfsToDb::insertTermsOfUse($aWfs);
     $featureTypeNameArray = array();
     for ($i = 0; $i < count($aWfs->featureTypeArray); $i++) {
         $currentFeatureType = $aWfs->featureTypeArray[$i];
         array_push($featureTypeNameArray, $currentFeatureType);
         if (WfsToDb::featureTypeExists($currentFeatureType)) {
             // update existing WFS feature types
             $e = new mb_exception("FT exists");
             if (!WfsToDb::updateFeatureType($currentFeatureType)) {
                 db_rollback();
                 return false;
             }
         } else {
             $e = new mb_exception("FT ne pas exists");
             // insert new feature types
             if (!WfsToDb::insertFeatureType($currentFeatureType)) {
                 db_rollback();
                 return false;
             }
         }
     }
     // delete obsolete WFS feature types
     $v = array($aWfs->id);
     $t = array("i");
     $sql = "DELETE FROM wfs_featuretype WHERE fkey_wfs_id = \$1";
     $sql_in = "";
     for ($i = 0; $i < count($featureTypeNameArray); $i++) {
         if ($i > 0) {
             $sql_in .= ", ";
         }
         $sql_in .= "\$" . ($i + 2);
         array_push($v, $featureTypeNameArray[$i]->name);
         array_push($t, "s");
     }
     if ($sql_in !== "") {
         $sql .= " AND featuretype_name NOT IN (" . $sql_in . ")";
     }
     $res = db_prep_query($sql, $v, $t);
     if (!$res) {
         $e = new mb_exception("Error while deleting obsolete WFS feature types in database.");
         db_rollback();
         return false;
     }
     db_commit();
     return true;
 }