|
|
@@ -45,7 +45,8 @@ class SqlQueryWhereBuilder {
|
|
|
foreach ($this->_log as $log) {
|
|
|
switch ($log) {
|
|
|
case 'open_block_and':
|
|
|
- case 'open_block_or': {
|
|
|
+ case 'open_block_or':
|
|
|
+ case 'open_block_not': {
|
|
|
$blockType = substr($log, 11);
|
|
|
array_push($sqlBlocksStack, $blockType);
|
|
|
$arr = array(); array_push($sqlValuesStack, $arr);
|
|
|
@@ -71,6 +72,25 @@ class SqlQueryWhereBuilder {
|
|
|
array_push($sqlValuesStack, $parentStackValue);
|
|
|
}
|
|
|
break;
|
|
|
+ case 'close_block_not': {
|
|
|
+ $blockType = substr($log, 12);
|
|
|
+ if (empty($sqlBlocksStack)) throw new Exception("parse sql query failed - blocks stack is empty");
|
|
|
+ $stackBlockType = array_pop($sqlBlocksStack);
|
|
|
+ if ($blockType != $stackBlockType) throw new Exception("parse sql query failed - expected stop '{$blockType}', given '{$stackBlockType}'");
|
|
|
+
|
|
|
+ // parse to string and add to parent value stack
|
|
|
+ $stackValue = array_pop($sqlValuesStack);
|
|
|
+ if (!is_array($stackValue)) throw new Exception("parse sql query failed - stack value is not array");
|
|
|
+ if (empty($stackValue)) throw new Exception("parse sql query failed - stack value is empty");
|
|
|
+ if (1 != count($stackValue)) throw new Exception("parse sql query failed - stack value count is not equal to 1");
|
|
|
+ $stackValue = reset($stackValue);
|
|
|
+ $sqlFromStack = " ! ({$stackValue}) ";
|
|
|
+ $parentStackValue = array_pop($sqlValuesStack);
|
|
|
+ if (!is_array($parentStackValue)) throw new Exception("parse sql query failed - parent stack value is not array");
|
|
|
+ array_push($parentStackValue, $sqlFromStack);
|
|
|
+ array_push($sqlValuesStack, $parentStackValue);
|
|
|
+ }
|
|
|
+ break;
|
|
|
default: {
|
|
|
if (is_array($log) && 4 == count($log) && 'comparisonFieldToValue' == $log[0]) {
|
|
|
$sqlFieldName = $log[1];
|
|
|
@@ -105,7 +125,7 @@ class SqlQueryWhereBuilder {
|
|
|
if ('and' == $blockType || 'or' == $blockType) {
|
|
|
return true;
|
|
|
} else if ('not' == $blockType) {
|
|
|
- return false;// TODO: allow not operator: expect only one children, if more -> use only last
|
|
|
+ return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|