mise a jour automatique des infos de version
[mtweb] / mw / app / data / modules / share / mw_data_versions.php
index 26bc0ee..1f539b4 100644 (file)
       return false;
     }
 
+    function set_version($application_name, $version){
+      if(
+        (
+          $data_version = $this->data_read(
+            array(
+              "table_name" => "versions",
+              "index_name" => "application",
+              "index_value" => $application_name
+            )
+          )
+        ) === false
+      ){
+        return false;
+      }
+      if($data_version){
+        if(
+          !$this->data_update(
+            array(
+              "table_name" => "versions",
+              "index_name" => "id",
+              "index_value" => $data_version["id"],
+              "values" => array(
+                "version" => $version
+              )
+            )
+          )
+        ){
+          return false;
+        }
+      }
+      else{
+        if(
+          !$this->data_insert(
+            array(
+              "table_name" => "versions",
+              "values" => array(
+                "application" => $application_name,
+                "version" => $version
+              )
+            )
+          )
+        ){
+          return false;
+        }
+      }
+      return true;
+    }
+
   }