3 class mw_data_config extends mw_data
6 function config($key = null)
7 { $sgbd = $this->sgbd();
9 if($rst = $sgbd->open_data("config"))
11 { while($v_rst = $sgbd->fetch_data($rst))
13 { if($v_rst["key"] == $key)
14 { $value = $v_rst["value"];
22 while($v_rst = $sgbd->fetch_data($rst))
24 { if(is_array($v_rst)) foreach($v_rst as $key => $_value)
25 { $value[$key] = $_value;
32 $sgbd->close_data($rst);
34 if(!isset($value)) return false;
38 function config_exists($key)
39 { $sgbd = $this->sgbd();
41 if($rst = $sgbd->open_data("config"))
42 { while($v_rst = $sgbd->fetch_data($rst))
44 { if(isset($v_rst[$key])) $exists++;
51 $sgbd->close_data($rst);
57 function set_config($key, $value)
58 { $sgbd = $this->sgbd();
60 if($rst = $sgbd->open_data("config"))
61 { while($v_rst = $sgbd->fetch_data($rst))
63 { if(array_key_exists($key, $v_rst))
64 { $FOUND = $sgbd->set_data("config", $v_rst["id"], array($key => $value));
73 $sgbd->close_data($rst);
77 { if($FOUND) return true;
79 { if($sgbd->add_data("config", array($key => $value))) return true;
85 function del_config($key)
87 $sgbd = $this->sgbd();
88 if($rst = $sgbd->open_data("config"))
89 { while($v_rst = $sgbd->fetch_data($rst))
91 { if(isset($v_rst[$key]) && isset($v_rst["id"]))
92 { $ids[] = $v_rst["id"];
97 $sgbd->close_data($rst);
99 if($ids === false) return false;
100 foreach($ids as $id) if(!$sgbd->del_data("config", $id)) return false;