syntaxe POO (visibilite) et maj indentation
[mw_sourceml] / app / data / modules / xml / sml_data_sources_cache_db.php
1 <?php
2
3   class sml_data_sources_cache_db extends mw_data{
4
5     public function source_cache_db(){
6       $sgbd = $this->sgbd();
7       $source_cache = array();
8       if($rst = $sgbd->open_data("sml_source_cache")){
9         while($v_rst = $sgbd->fetch_data($rst)){
10           if(isset($v_rst)){
11             if(isset($v_rst["id"])) $source_cache[$v_rst["id"]] = $v_rst;
12           }
13           else{
14             $source_cache = false;
15             $break;
16           }
17         }
18         $sgbd->close_data($rst);
19       }
20       else $source_cache = false;
21       return $source_cache;
22     }
23
24     public function source_cache_infos_db($url){
25       $sgbd = $this->sgbd();
26       $cache_infos = array();
27       if($rst = $sgbd->open_data("sml_source_cache")){
28         while($v_rst = $sgbd->fetch_data($rst)){
29           if(isset($v_rst)){
30             if(isset($v_rst["id"]) && isset($v_rst["url"])){
31               if($v_rst["url"] == $url){
32                 $cache_infos = $v_rst;
33                 $break;
34               }
35             }
36           }
37           else{
38             $cache_infos = false;
39             $break;
40           }
41         }
42         $sgbd->close_data($rst);
43       }
44       else $cache_infos = false;
45       return $cache_infos;
46     }
47
48     public function add_source_cache_db($url, $cache_index){
49       $sgbd = $this->sgbd();
50       return $sgbd->add_data(
51         "sml_source_cache",
52         array(
53           "url" => $url,
54           "id_source" => $cache_index,
55           "last_update" => date("Y-m-d H:i:s")
56         )
57       ) ? true : false;
58     }
59
60     public function del_source_cache_db($id_cache_data){
61       $sgbd = $this->sgbd();
62       return $sgbd->del_data("sml_source_cache", $id_cache_data) ? true : false;
63     }
64
65   }