Aggiunta ricerche datatables con filtro per simbolo "="

This commit is contained in:
loviuz 2020-01-09 18:40:12 +01:00
parent 9cd21bee23
commit d03c2c8aaf
1 changed files with 11 additions and 3 deletions

View File

@ -174,17 +174,25 @@ class Query
$real_value = trim(str_replace(['&lt;', '&gt;'], ['<', '>'], $value));
$more = starts_with($real_value, '>=') || starts_with($real_value, '> =') || starts_with($real_value, '>');
$minus = starts_with($real_value, '<=') || starts_with($real_value, '< =') || starts_with($real_value, '<');
$equal = starts_with($real_value, '=');
if ($minus || $more) {
if ($minus || $more || $equal) {
$sign = str_contains($real_value, '=') ? '=' : '';
if ($more) {
$sign = '>'.$sign;
} else {
} elseif ($minus) {
$sign = '<'.$sign;
} else {
$sign = '=';
}
$value = trim(str_replace(['&lt;', '=', '&gt;'], '', $value));
$search_filters[] = 'CAST('.$search_query.' AS UNSIGNED) '.$sign.' '.prepare($value);
if ($more || $minus){
$search_filters[] = 'CAST('.$search_query.' AS UNSIGNED) '.$sign.' '.prepare($value);
} else {
$search_filters[] = $search_query.' = '.prepare($value);
}
} else {
$search_filters[] = $search_query.' LIKE '.prepare('%'.$value.'%');
}