3 class mw_data_config extends mw_data{
5 function config($key = null){
11 $sql = "SELECT `value` FROM #--config WHERE `key`=".$this->eq($key);
12 $rst = $sgbd->query($sql);
13 if($v_rst = $sgbd->fetch_assoc($rst)) $value = $v_rst["value"];
14 $sgbd->free_result($rst);
18 $sql = "SELECT * FROM #--config";
19 $rst = $sgbd->query($sql);
20 while($v_rst = $sgbd->fetch_assoc($rst)) $value[$v_rst["key"]] = $v_rst["value"];
21 $sgbd->free_result($rst);
24 catch(Exception $e) { $value = false; }
28 function config_exists($key){
29 $sgbd = $this->sgbd();
32 $sql = "SELECT count(*) as n FROM #--config WHERE `key`=".$this->eq($key);
33 $rst = $sgbd->query($sql);
34 if($v_rst = $sgbd->fetch_assoc($rst)) $exists = $v_rst["n"];
35 $sgbd->free_result($rst);
37 catch(Exception $e) { $exists = false; }
41 function set_config($key, $value){
42 $sgbd = $this->sgbd();
43 if(($exists = $this->config_exists($key)) === false) return false;
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).")";
54 catch(Exception $e) { return false; }
58 function del_config($key){
59 $sgbd = $this->sgbd();
61 $sql = "DELETE FROM #--config WHERE `key`=".$this->eq($key);
64 catch(Exception $e) { return false; }