3 class mw_data_config extends mw_data{
5 function config($key = null){
10 "SELECT `value` FROM #--config"
11 ." WHERE `key`=".$this->eq($key);
12 $rst = $sgbd->query($sql);
13 if(!isset($rst)) return false;
14 if($v_rst = $sgbd->fetch_assoc($rst)) $value = $v_rst["value"];
16 $sgbd->free_result($rst);
21 "SELECT * FROM #--config";
22 $rst = $sgbd->query($sql);
23 if(!isset($rst)) return false;
24 while($v_rst = $sgbd->fetch_assoc($rst)) $value[$v_rst["key"]] = $v_rst["value"];
25 $sgbd->free_result($rst);
30 function config_exists($key){
31 $sgbd = $this->sgbd();
33 $sql = "SELECT count(*) as n FROM #--config"
34 ." WHERE `key`=".$this->eq($key);
35 $rst = $sgbd->query($sql);
36 if(!isset($rst)) return false;
37 if($v_rst = $sgbd->fetch_assoc($rst)) $exists = $v_rst["n"];
38 $sgbd->free_result($rst);
42 function set_config($key, $value){
43 $sgbd = $this->sgbd();
44 if($this->config_exists($key)) $sql =
46 ." SET `value`=".$this->eq($value)
47 ." WHERE `key`=".$this->eq($key);
49 "INSERT INTO #--config"
50 ." VALUES(NULL, ".$this->eq($key).", ".$this->eq($value).")";
51 $rst = $sgbd->query($sql);
52 if(!isset($rst)) return false;
56 function del_config($key){
57 $sgbd = $this->sgbd();
58 return $sgbd->query("DELETE FROM #--config WHERE `key`=".$this->eq($key)) ? true : false;