clear_querys(); $this -> clear_counts(); } //clear querys function clear_querys() { $this -> query_str = ""; $this -> query_select = ""; $this -> query_from = ""; $this -> query_where = ""; $this -> query_orderby = ""; $this -> query_table = ""; $this -> query_field = ""; $this -> query_value = ""; } //clear counts function clear_counts() { $this -> currentFieldnum = 0; $this -> currentRownum = 0; } //make query function make( $_mode = "select"){ $ret_code = false; $this -> errorMessage = ""; switch ($_mode){ case "select"; if ($this -> query_select != "" ) { if ($this -> query_from != "" ) { $ret_code = true; $this -> query_str = "select ".$this ->query_select; $this -> query_str = $this -> query_str." from ".$this -> query_from; if ($this -> query_where != "" ) { $this -> query_str = $this -> query_str." where ".$this -> query_where; }; if ($this -> query_orderby != "" ) { $this -> query_str = $this -> query_str." order by ".$this -> query_orderby; }; }; }; break; case "insert"; case "update"; case "delete"; default; $this -> errorMessage = "対応していないmodeです.(selectのみ対応)"; } return $ret_code; } // execute query function exec( $_mode = "select"){ $ret_code = $this -> make($_mode); if ($ret_code) $ret_code = $this -> execute($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"; $ret_code = $this->_add($this->query_select,$_note,$_mode); break; case "from"; $ret_code = $this->_add($this->query_from,$_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 "table"; case "value"; case "field"; default; $this -> errorMessage = "指定できないtypeです.(select : from : where : orderby)"; } return $ret_code; } //get fieldnames function getfieldname() { if ($this -> currentFieldnum >= $this -> colcount) { $this -> currentFieldnum = 0; return false; } else { //$s = pg_fieldname($this -> queryresult,$this -> currentFieldnum); // - PHP4.2.0 $s = pg_field_name($this -> queryresult,$this -> currentFieldnum); // PHP4.2.0 - ++$this -> currentFieldnum; return $s; }; } //get rows function getrow() { if ($this -> currentRownum >= $this -> rowcount) { $this -> currentRownum = 0; return false; } else { $s = pg_fetch_row($this -> queryresult, $this -> currentRownum); ++$this -> currentRownum; return $s; }; } } ?>