2497e5892a4da1bdf52df1f41cdab206759b2abf
[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     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) { $cache = false; }
15       return $cache;
16     }
17
18     function source_cache_infos_db($url){
19       $sgbd = $this->sgbd();
20       $cache_infos = array();
21       try{
22         $sql = "SELECT * FROM #--sml_source_cache WHERE url=".$this->eq($url);
23         $rst = $sgbd->query($sql);
24         if($v_rst = $sgbd->fetch_assoc($rst)) $cache_infos = $v_rst;
25         $sgbd->free_result($rst);
26       }
27       catch(Exception $e) { $cache_infos = false; }
28       return $cache_infos;
29     }
30
31     function add_source_cache_db($url, $cache_index){
32       $sgbd = $this->sgbd();
33       try{
34         $sql =
35          "INSERT INTO #--sml_source_cache(url, id_source, last_update) VALUES"
36         ."( ".$this->eq($url)
37         .", ".$cache_index
38         .", '".date("Y-m-d H:i:s")."'"
39         .")";
40         $sgbd->query($sql);
41       }
42       catch(Exception $e) { return false; }
43       return true;
44     }
45
46     function del_source_cache_db($id_cache_data){
47       $env = $this->env();
48       $sgbd = $this->sgbd();
49       try{
50         $sql = "DELETE FROM #--sml_source_cache WHERE id=".$this->eq($id_cache_data);
51         $sgbd->query($sql);
52       }
53       catch(Exception $e) { return false; }
54       return true;
55     }
56
57   }
58
59 ?>