function copy() { $newResultSet = new ResultSet(); $newResultSet->copyColumData($this); $this->reset(); $newResultSet->reset(); while ($this->next()) { $newResultSet->appendRow($this->rows[$this->pos]->fields, $this->rows[$this->pos]->id); } return $newResultSet; }
function filterRowsByAndConditions($params1, $params2, $operators) { $rs = new ResultSet(); $rs->copyColumData($this); $this->reset(); $colNrs1 = array(); $colNrs2 = array(); // find column nr's for params1 -1=no column, its a direct value for ($i = 0; $i < count($params1); ++$i) { if (($colNrs1[$i] = $this->findColNrByFullName($params1[$i])) == NOT_FOUND) { if (has_quotes($params1[$i]) || is_numeric($params1[$i])) { $colNrs1[$i] = -1; if (has_quotes($params1[$i])) { remove_quotes($params1[$i]); } } else { print_error_msg("Column '" . $params1[$i] . "' not found"); return null; } } } // find column nr's for params2 -1=no column, its a direct value for ($i = 0; $i < count($params2); ++$i) { if (($colNrs2[$i] = $this->findColNrByFullName($params2[$i])) == NOT_FOUND) { if (has_quotes($params2[$i]) || is_numeric($params2[$i])) { $colNrs2[$i] = -1; if (has_quotes($params2[$i])) { remove_quotes($params2[$i]); } } else { print_error_msg("Column '" . $params2[$i] . "' not found"); return null; } } } $val1 = ""; $val2 = ""; $this->reset(); while (++$this->pos < count($this->rows)) { $recMetsConds = true; for ($i = 0; $i < count($params1); ++$i) { if ($colNrs1[$i] == -1) { $val1 = $params1[$i]; } else { $val1 = $this->rows[$this->pos]->fields[$colNrs1[$i]]; } if ($colNrs2[$i] == -1) { $val2 = $params2[$i]; } else { $val2 = $this->rows[$this->pos]->fields[$colNrs2[$i]]; } if (!compare($val1, $val2, $operators[$i])) { $recMetsConds = false; break; } } if ($recMetsConds) { $rs->append(false); $rs->rows[$rs->pos]->fields = $this->rows[$this->pos]->fields; $rs->rows[$rs->pos]->id = $this->rows[$this->pos]->id; } } // reset ResultSet's $this->reset(); $rs->reset(); return $rs; }