function SQLWhere($SearchFor, $strSearchOption, $SearchFor2, $etype, $isSuggest) { $baseResult = $this->baseSQLWhere($strSearchOption); if ($baseResult === false) { return ""; } if ($baseResult != "") { return $baseResult; } if ($SearchFor == "none" || $SearchFor != "on" && $SearchFor != "off") { return ""; } $fullFieldName = $this->getFieldSQLDecrypt(); $bNeedQuotes = NeedQuotes($this->type); return CheckboxField::constructFieldWhere($fullFieldName, $bNeedQuotes, $SearchFor == "on", $this->type, $this->connection->dbType); }
/** * Get an SQL string containing the intervals totals * to add them then to the SELECT clause * @return String */ protected function getTotals() { $type = $this->pSet->getFieldType($this->fName); $bNeedQuotes = NeedQuotes($type); $fullFieldName = $this->getDbFieldName($this->fName); $fullTotalFieldName = $this->getDbFieldName($this->totalsfName); $booleanData = array("checked", "unchecked"); $totals = array(); foreach ($booleanData as $type) { $checked = $type == "checked"; $caseCondition = CheckboxField::constructFieldWhere($fullFieldName, $bNeedQuotes, $checked, $type, $this->connection->dbType); $caseStatement = $this->getCaseStatement($caseCondition, $fullTotalFieldName, "null"); $totals[] = $this->aggregate . "(" . $caseStatement . ") as " . $this->connection->addFieldWrappers($type); if ($this->useTotals && $this->fName != $this->totalsfName) { $caseStatement = $this->getCaseStatement($caseCondition, $fullFieldName, "null"); $totals[] = $this->aggregate . "(" . $caseStatement . ") as " . $this->connection->addFieldWrappers($this->fName . $type); } } return implode(", ", $totals); }
/** * Get filter's WHERE clause condition basing on the filter's type * * @param String filterType A string representing the filter's type * @param String fName * @param String fValue * @param String dbType * @return String */ function getFilterWhereByType($filterType, $fName, $fValue, $sValue, $parentValues, $connection) { $pSet = new ProjectSettings($this->tName, PAGE_SEARCH); $fullFieldName = RunnerPage::_getFieldSQLDecrypt($fName, $connection, $pSet, $this->cipherer); $fieldType = $pSet->getFieldType($fName); $dateField = IsDateFieldType($fieldType); $timeField = IsTimeType($fieldType); if ($dateField || $timeField) { include_once getabspath("classes/controls/FilterControl.php"); include_once getabspath("classes/controls/FilterIntervalSlider.php"); include_once getabspath("classes/controls/FilterIntervalDateSlider.php"); } switch ($filterType) { case 'interval': $intervalData = $pSet->getFilterIntervalDatabyIndex($fName, $fValue); if (!count($intervalData)) { return ""; } include_once getabspath("classes/controls/FilterControl.php"); include_once getabspath("classes/controls/FilterIntervalList.php"); return FilterIntervalList::getIntervalFilterWhere($fName, $intervalData, $pSet, $this->cipherer, $this->tName, $connection); case 'equals': if (!count($parentValues)) { return $fullFieldName . "=" . $this->cipherer->MakeDBValue($fName, $fValue, "", true); } $wheres = array(); $wheres[] = $fullFieldName . "=" . $this->cipherer->MakeDBValue($fName, $fValue, "", true); $parentFiltersNames = $pSet->getParentFiltersNames($fName); foreach ($parentFiltersNames as $key => $parentName) { $wheres[] = RunnerPage::_getFieldSQLDecrypt($parentName, $connection, $pSet, $this->cipherer) . "=" . $this->cipherer->MakeDBValue($parentName, $parentValues[$key], "", true); } return "(" . implode(" AND ", $wheres) . ")"; case 'checked': if ($fValue != "on" && $fValue != "off") { return ""; } $bNeedQuotes = NeedQuotes($fieldType); include_once getabspath("classes/controls/Control.php"); include_once getabspath("classes/controls/CheckboxField.php"); return CheckboxField::constructFieldWhere($fullFieldName, $bNeedQuotes, $fValue == "on", $pSet->getFieldType($fName), $connection->dbType); case 'slider': if ($dateField) { return FilterIntervalDateSlider::getDateSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } if ($timeField) { include_once getabspath("classes/controls/FilterIntervalTimeSlider.php"); return FilterIntervalTimeSlider::getTimeSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } return $this->cipherer->MakeDBValue($fName, $fValue, "", true) . "<=" . $fullFieldName . " AND " . $fullFieldName . "<=" . $this->cipherer->MakeDBValue($fName, $sValue, "", true); case 'moreequal': if ($dateField) { return FilterIntervalDateSlider::getDateSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } if ($timeField) { include_once getabspath("classes/controls/FilterIntervalTimeSlider.php"); return FilterIntervalTimeSlider::getTimeSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } return $this->cipherer->MakeDBValue($fName, $fValue, "", true) . "<=" . $fullFieldName; case 'lessequal': if ($dateField) { return FilterIntervalDateSlider::getDateSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } if ($timeField) { include_once getabspath("classes/controls/FilterIntervalTimeSlider.php"); return FilterIntervalTimeSlider::getTimeSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } return $fullFieldName . "<=" . $this->cipherer->MakeDBValue($fName, $fValue, "", true); default: return ""; } }