public attr / function, constructeurs __construct
[mtweb] / mw / app / data / modules / share / mw_data_versions.php
1 <?php
2
3   class mw_data_versions extends mw_data{
4
5     public function version($application_name){
6       if(
7         $version = $this->data_read(
8           array(
9             "table_name" => "versions",
10             "index_name" => "application",
11             "index_value" => $application_name
12           )
13         )
14       ) return $version["version"];
15       return false;
16     }
17
18     public function set_version($application_name, $version){
19       if(
20         (
21           $data_version = $this->data_read(
22             array(
23               "table_name" => "versions",
24               "index_name" => "application",
25               "index_value" => $application_name
26             )
27           )
28         ) === false
29       ){
30         return false;
31       }
32       if($data_version){
33         if(
34           !$this->data_update(
35             array(
36               "table_name" => "versions",
37               "index_name" => "id",
38               "index_value" => $data_version["id"],
39               "values" => array(
40                 "version" => $version
41               )
42             )
43           )
44         ){
45           return false;
46         }
47       }
48       else{
49         if(
50           !$this->data_insert(
51             array(
52               "table_name" => "versions",
53               "values" => array(
54                 "application" => $application_name,
55                 "version" => $version
56               )
57             )
58           )
59         ){
60           return false;
61         }
62       }
63       return true;
64     }
65
66   }