3 class mw_data_config extends mw_data{
5 function config($key = null){
8 if($rst = $sgbd->open_data("config")){
10 while($v_rst = $sgbd->fetch_data($rst)){
12 if($v_rst["key"] == $key){
13 $value = $v_rst["value"];
21 while($v_rst = $sgbd->fetch_data($rst)){
23 if(is_array($v_rst)) foreach($v_rst as $key => $_value){
24 $value[$key] = $_value;
31 $sgbd->close_data($rst);
33 if(!isset($value)) return false;
37 function config_exists($key){
38 $sgbd = $this->sgbd();
40 if($rst = $sgbd->open_data("config")){
41 while($v_rst = $sgbd->fetch_data($rst)){
43 if(isset($v_rst[$key])) $exists++;
50 $sgbd->close_data($rst);
56 function set_config($key, $value){
57 $sgbd = $this->sgbd();
59 if($rst = $sgbd->open_data("config")){
60 while($v_rst = $sgbd->fetch_data($rst)){
62 if(array_key_exists($key, $v_rst)){
63 $FOUND = $sgbd->set_data("config", $v_rst["id"], array($key => $value));
72 $sgbd->close_data($rst);
76 if($FOUND) return true;
78 if($sgbd->add_data("config", array($key => $value))) return true;
84 function del_config($key){
86 $sgbd = $this->sgbd();
87 if($rst = $sgbd->open_data("config")){
88 while($v_rst = $sgbd->fetch_data($rst)){
90 if(isset($v_rst[$key]) && isset($v_rst["id"])){
91 $ids[] = $v_rst["id"];
96 $sgbd->close_data($rst);
98 if($ids === false) return false;
99 foreach($ids as $id) if(!$sgbd->del_data("config", $id)) return false;