9700fddde1224f55eb362fe88a5270e279886a0a
[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
6     function source_cache_db()
7     { $sgbd = $this->sgbd();
8       $source_cache = array();
9       if($rst = $sgbd->open_data("sml_source_cache"))
10       { while($v_rst = $sgbd->fetch_data($rst))
11         { if(isset($v_rst))
12           { if(isset($v_rst["id"])) $source_cache[$v_rst["id"]] = $v_rst;
13           }
14           else
15           { $source_cache = false;
16             $break;
17           }
18         }
19         $sgbd->close_data($rst);
20       }
21       else $source_cache = false;
22       return $source_cache;
23     }
24
25     function source_cache_infos_db($url)
26     { $sgbd = $this->sgbd();
27       $cache_infos = array();
28       if($rst = $sgbd->open_data("sml_source_cache"))
29       { while($v_rst = $sgbd->fetch_data($rst))
30         { if(isset($v_rst))
31           { if(isset($v_rst["id"]) && isset($v_rst["url"]))
32             { if($v_rst["url"] == $url)
33               { $cache_infos = $v_rst;
34                 $break;
35               }
36             }
37           }
38           else
39           { $cache_infos = false;
40             $break;
41           }
42         }
43         $sgbd->close_data($rst);
44       }
45       else $cache_infos = false;
46       return $cache_infos;
47     }
48
49     function add_source_cache_db($url, $cache_index)
50     { $sgbd = $this->sgbd();
51       return $sgbd->add_data
52       ( "sml_source_cache",
53         array
54         ( "url" => $url,
55           "id_source" => $cache_index,
56           "last_update" => date("Y-m-d H:i:s")
57         )
58       ) ? true : false;
59     }
60
61     function del_source_cache_db($id_cache_data)
62     { $sgbd = $this->sgbd();
63       return $sgbd->del_data("sml_source_cache", $id_cache_data) ? true : false;
64     }
65
66   }
67
68 ?>