query_str = ""; $this -> query_where = ""; $this -> query_orderby = ""; $this -> query_groupby = ""; $this -> query_table = ""; $this -> query_field = ""; $this -> query_value = ""; } //make query function make( $_mode = "select"){ $ret_code = false; $this -> errormessage = ""; switch ($_mode){ case "select"; if ($this -> query_field != "" ) { if ($this -> query_table != "" ) { $ret_code = true; $this -> query_str = "select ".$this ->query_field; $this -> query_str = $this -> query_str." from ".$this -> query_table; if ($this -> query_where != "" ) { $this -> query_str = $this -> query_str." where ".$this -> query_where; }; if ($this -> query_groupby != "" ) { $this -> query_str = $this -> query_str." group by ".$this -> query_groupby; }; if ($this -> query_orderby != "" ) { $this -> query_str = $this -> query_str." order by ".$this -> query_orderby; }; }; }; break; case "insert"; if ($this -> query_table != "" ) { if ($this -> query_value != "" ) { $ret_code = true; $this -> query_str = "insert into ".$this -> query_table; if ($this -> query_field != "" ) { $this -> query_str = $this -> query_str."(".$this -> query_field.")";}; $this -> query_str = $this -> query_str." values (".$this -> query_value.")"; }; }; break; case "update"; if ($this -> query_table != "" ) { if ($this -> query_value != "" ) { if ($this -> query_where != "" ) { $ret_code = true; $this -> query_str = "update ".$this -> query_table; $this -> query_str = $this -> query_str." set ".$this -> query_value; $this -> query_str = $this -> query_str." where ".$this -> query_where; }; }; }; break; case "delete"; if ($this -> query_table != "" ) { if ($this -> query_where != "" ) { $ret_code = true; $this -> query_str = "delete from ".$this -> query_table; $this -> query_str = $this -> query_str." where ".$this -> query_where; }; }; break; default; $this -> errormessage = "対応していないmodeです.(select : insert : update : delete)"; } if($ret_code) $ret_code = $this->query_str; return $ret_code; } //(sub function) add querystr function _add(&$_pstr,$_note,$_mode){ if ($_mode == "new") $_pstr = ""; elseif($_pstr != "" ) $_pstr = $_pstr." ".$_mode." "; $_pstr = $_pstr.$_note; return true; } //add querystr function add( $_note = "",$_type = "select" , $_mode = "and"){ $ret_code = false; $this -> errormessage = ""; // check mode switch($_mode){ case "and"; break; case "or"; break; case ","; break; case "new"; break; default; $this -> errormessage = "指定できないmodeです.(and : or : , : new)"; return $ret_code; } if ($_note == ""){ $this -> errormessage = "追加するクエリーがありません."; return $ret_code; } switch($_type){ case "select"; case "field"; $ret_code = $this->_add($this->query_field,$_note,$_mode); break; case "from"; case "into"; case "table"; $ret_code = $this->_add($this->query_table,$_note,$_mode); break; case "where"; $ret_code = $this->_add($this->query_where,$_note,$_mode); break; case "orderby"; $ret_code = $this->_add($this->query_orderby,$_note,$_mode); break; case "groupby"; $ret_code = $this->_add($this->query_groupby,$_note,$_mode); break; case "values"; case "set"; case "value"; // 旧クラスとの互換性のため $ret_code = $this->_add($this->query_value,$_note,$_mode); break; default; $this -> errormessage = "指定できないtypeです.(select : from : where : orderby : groupby : table : values : set : field : into)"; } return $ret_code; } //set parameter function set($_field = "" , $_value = "", $_sign = "=", $_mode = "auto"){ $ret_code = false; if ($_field <> ""){ switch($_mode){ case "auto"; if(!is_numeric($_value)) $_value = "'".$_value."'"; break; case "str"; $_value = "'".$_value."'"; break; } $ret_code = $_field." ".$_sign." ".$_value; } return $ret_code; } } ?>