3 class mw_data_config extends mw_data
6 function config($key = null)
7 { $sgbd = $this->sgbd();
11 "SELECT `value` FROM #--config"
12 ." WHERE `key`=".$this->eq($key);
13 $rst = $sgbd->query($sql);
14 if(!isset($rst)) return false;
15 if($v_rst = $sgbd->fetch_assoc($rst)) $value = $v_rst["value"];
17 $sgbd->free_result($rst);
22 "SELECT * FROM #--config";
23 $rst = $sgbd->query($sql);
24 if(!isset($rst)) return false;
25 while($v_rst = $sgbd->fetch_assoc($rst)) $value[$v_rst["key"]] = $v_rst["value"];
26 $sgbd->free_result($rst);
31 function config_exists($key)
32 { $sgbd = $this->sgbd();
34 $sql = "SELECT count(*) as n FROM #--config"
35 ." WHERE `key`=".$this->eq($key);
36 $rst = $sgbd->query($sql);
37 if(!isset($rst)) return false;
38 if($v_rst = $sgbd->fetch_assoc($rst)) $exists = $v_rst["n"];
39 $sgbd->free_result($rst);
43 function set_config($key, $value)
44 { $sgbd = $this->sgbd();
45 if($this->config_exists($key)) $sql =
47 ." SET `value`=".$this->eq($value)
48 ." WHERE `key`=".$this->eq($key);
50 "INSERT INTO #--config"
51 ." VALUES(NULL, ".$this->eq($key).", ".$this->eq($value).")";
52 $rst = $sgbd->query($sql);
53 if(!isset($rst)) return false;
57 function del_config($key)
58 { $sgbd = $this->sgbd();
59 return $sgbd->query("DELETE FROM #--config WHERE `key`=".$this->eq($key)) ? true : false;