private function _getWhereClause()
{
$where_clause = '';
$criteria_cnt = 0;
for ($column_index = 0; $column_index < $this->_criteria_column_count; $column_index++) {
if (!empty($this->_formColumns[$column_index]) && !empty($this->_formCriterions[$column_index]) && $column_index && isset($last_where) && isset($this->_formAndOrCols)) {
$where_clause .= ' ' . mb_strtoupper($this->_formAndOrCols[$last_where]) . ' ';
}
if (!empty($this->_formColumns[$column_index]) && !empty($this->_formCriterions[$column_index])) {
$where_clause .= '(' . $this->_formColumns[$column_index] . ' ' . $this->_formCriterions[$column_index] . ')';
$last_where = $column_index;
$criteria_cnt++;
}
}
// end for
if ($criteria_cnt > 1) {
$where_clause = '(' . $where_clause . ')';
}
// OR rows ${'cur' . $or}[$column_index]
if (!isset($this->_formAndOrRows)) {
$this->_formAndOrRows = array();
}
for ($row_index = 0; $row_index <= $this->_criteria_row_count; $row_index++) {
$criteria_cnt = 0;
$qry_orwhere = '';
$last_orwhere = '';
for ($column_index = 0; $column_index < $this->_criteria_column_count; $column_index++) {
if (!empty($this->_formColumns[$column_index]) && !empty($_REQUEST['Or' . $row_index][$column_index]) && $column_index) {
$qry_orwhere .= ' ' . mb_strtoupper($this->_formAndOrCols[$last_orwhere]) . ' ';
}
if (!empty($this->_formColumns[$column_index]) && !empty($_REQUEST['Or' . $row_index][$column_index])) {
$qry_orwhere .= '(' . $this->_formColumns[$column_index] . ' ' . $_REQUEST['Or' . $row_index][$column_index] . ')';
$last_orwhere = $column_index;
$criteria_cnt++;
}
}
// end for
if ($criteria_cnt > 1) {
$qry_orwhere = '(' . $qry_orwhere . ')';
}
if (!empty($qry_orwhere)) {
$where_clause .= "\n" . mb_strtoupper(isset($this->_formAndOrRows[$row_index]) ? $this->_formAndOrRows[$row_index] . ' ' : '') . $qry_orwhere;
}
// end if
}
// end for
if (!empty($where_clause) && $where_clause != '()') {
$where_clause = 'WHERE ' . htmlspecialchars($where_clause) . "\n";
}
// end if
return $where_clause;
}