break;
case 'mhas':
- // mhas == multiple has
- if ($value !== NULL && count($value) > 0) {
- $sqlOP = $this->getSQLOperator($op);
- $value = CRM_Utils_Type::escapeAll($value, $type);
- $clause
- = "{$field['dbAlias']} REGEXP '[[:cntrl:]]" . implode('|', $value) .
- "[[:cntrl:]]'";
- }
- break;
-
case 'mnot':
- // mhas == multiple has
- // mnot == multiple is not one of
++ // multiple has or multiple not
if ($value !== NULL && count($value) > 0) {
-- $sqlOP = $this->getSQLOperator($op);
- $operator = '';
- if ($op == 'mnot') {
- // mnot == multiple is not one of
- $operator = 'NOT';
- }
+ $value = CRM_Utils_Type::escapeAll($value, $type);
- $clause
- = "( {$field['dbAlias']} NOT REGEXP '[[:cntrl:]]" . implode('|', $value) .
- "[[:cntrl:]]' OR {$field['dbAlias']} IS NULL )";
++ $operator = $op == 'mnot' ? 'NOT' : '';
+ $regexp = "[[:cntrl:]]*" . implode('[[:>:]]*|[[:<:]]*', (array) $value) . "[[:cntrl:]]*";
+ $clause = "{$field['dbAlias']} {$operator} REGEXP '{$regexp}'";
}
break;