syntaxe POO (visibilite) et maj indentation
[mw_sourceml] / app / data / modules / sql / 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       $cache = array();
8       try{
9         $sql = "SELECT * FROM #--sml_source_cache";
10         $rst = $sgbd->query($sql);
11         while($v_rst = $sgbd->fetch_assoc($rst)) $cache[$v_rst["id"]] = $v_rst;
12         $sgbd->free_result($rst);
13       }
14       catch(Exception $e){
15         $cache = false;
16       }
17       return $cache;
18     }
19
20     public function source_cache_infos_db($url){
21       $sgbd = $this->sgbd();
22       $cache_infos = array();
23       try{
24         $sql = "SELECT * FROM #--sml_source_cache WHERE url=".$this->eq($url);
25         $rst = $sgbd->query($sql);
26         if($v_rst = $sgbd->fetch_assoc($rst)) $cache_infos = $v_rst;
27         $sgbd->free_result($rst);
28       }
29       catch(Exception $e){
30         $cache_infos = false;
31       }
32       return $cache_infos;
33     }
34
35     public function add_source_cache_db($url, $cache_index){
36       $sgbd = $this->sgbd();
37       try{
38         $sql =
39          "INSERT INTO #--sml_source_cache(url, id_source, last_update) VALUES"
40         ."( ".$this->eq($url)
41         .", ".$cache_index
42         .", '".date("Y-m-d H:i:s")."'"
43         .")";
44         $sgbd->query($sql);
45       }
46       catch(Exception $e){
47         return false;
48       }
49       return true;
50     }
51
52     public function del_source_cache_db($id_cache_data){
53       $env = $this->env();
54       $sgbd = $this->sgbd();
55       try{
56         $sql = "DELETE FROM #--sml_source_cache WHERE id=".$this->eq($id_cache_data);
57         $sgbd->query($sql);
58       }
59       catch(Exception $e){
60         return false;
61       }
62       return true;
63     }
64
65   }