support not equals

This commit is contained in:
2023-03-10 15:35:15 +10:00
parent 3bd5c064c3
commit a9b480994a

View File

@@ -133,7 +133,7 @@ class Conductor {
$value = trim($value);
// Check if value has a prefix and remove it if it's a number
if (preg_match('/^([<>]=?)(\d+\.?\d*)$/', $value, $matches)) {
if (preg_match('/^([<>!=]=?)(\d+\.?\d*)$/', $value, $matches)) {
$prefix = $matches[1];
$value = $matches[2];
} else {
@@ -143,8 +143,11 @@ class Conductor {
// If the value starts with '=', exact match
if (strpos($value, '=') === 0) {
$query->where($field, '=', substr($value, 1));
} else if (strpos($value, '!=') === 0) {
$query->where($field, '<>', substr($value, 2));
} else if (strpos($value, '!') === 0) {
$query->where($field, 'NOT LIKE', '%'.substr($value, 1).'%');
} else {
// Otherwise, use LIKE with '%value%'
$query->where($field, 'LIKE', "%$value%");
}
@@ -163,6 +166,10 @@ class Conductor {
case '<=':
$query->where($field, '<=', $value);
break;
case '!=':
case '<>':
$query->where($field, '<>', $value);
break;
}
}
}