|
|
@@ -29,6 +29,16 @@ class SqlQueryWhereBuilder {
|
|
|
$this->_log[] = array('comparisonFieldToValue', $fieldName, $sqlCompSign, $value);
|
|
|
}
|
|
|
|
|
|
+ public function addComparisonFieldFunToValue($fieldFun, $fieldName, $comparisonSign, $value) {
|
|
|
+ $sqlCompSign = "";
|
|
|
+ switch ($comparisonSign) {
|
|
|
+ case '=': $sqlCompSign = '='; break;
|
|
|
+ case 'like': $sqlCompSign = 'like'; break;
|
|
|
+ default: throw new Exception("Unsupported comparison sign");
|
|
|
+ }
|
|
|
+ $this->_log[] = array('comparisonFieldFunToValue', $fieldFun, $fieldName, $sqlCompSign, $value);
|
|
|
+ }
|
|
|
+
|
|
|
public function sql_filter_comparisonFieldIsNull($fieldName) {
|
|
|
$this->_log[] = array('comparisonFieldIsNull', $fieldName);
|
|
|
}
|
|
|
@@ -106,6 +116,16 @@ class SqlQueryWhereBuilder {
|
|
|
array_push($sqlValuesStack, $stackValue);
|
|
|
//echo "L.".__LINE__.":sqlBlocksStack:" . json_encode($sqlBlocksStack) . "\n";
|
|
|
//echo "L.".__LINE__.":sqlValuesStack:" . json_encode($sqlValuesStack) . "\n\n";
|
|
|
+ } else if (is_array($log) && 5 == count($log) && 'comparisonFieldFunToValue' == $log[0]) {
|
|
|
+ $sqlFieldFunName = $log[1];
|
|
|
+ if (strtolower($sqlFieldFunName) != 'geometrytype') throw new Exception("Unsupported db function {$sqlFieldName}");
|
|
|
+ $sqlFieldName = $log[2];
|
|
|
+ $this->_usedFields[$sqlFieldName] = true;
|
|
|
+ $sqlFromStack = "{$sqlFieldFunName}({tablePrefix}`{$sqlFieldName}`) {$log[3]} '{$log[4]}'";
|
|
|
+ $stackValue = array_pop($sqlValuesStack);
|
|
|
+ if (!is_array($stackValue)) throw new Exception("parse sql query failed - stack value is not array");
|
|
|
+ array_push($stackValue, $sqlFromStack);
|
|
|
+ array_push($sqlValuesStack, $stackValue);
|
|
|
} else if (is_array($log) && 2 == count($log) && 'comparisonFieldIsNull' == $log[0]) {
|
|
|
$sqlFieldName = $log[1];
|
|
|
$sqlFromStack = "{tablePrefix}`{$sqlFieldName}` is null";
|