From 7de012905d60d1e309e8635966ed9eca721b3ece Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Wed, 3 May 2023 10:33:10 +0200 Subject: [PATCH] Miglioria filtro = e != nelle tabelle --- src/Util/Query.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Util/Query.php b/src/Util/Query.php index af8dcb0b6..029db4620 100755 --- a/src/Util/Query.php +++ b/src/Util/Query.php @@ -201,25 +201,28 @@ class Query $equal = string_starts_with($real_value, '='); $notequal = string_starts_with($real_value, '!='); - if ($minus || $more || $equal || $notequal) { + if ($minus || $more) { $sign = string_contains($real_value, '=') ? '=' : ''; if ($more) { $sign = '>'.$sign; } elseif ($minus) { $sign = '<'.$sign; - } elseif ($equal) { - $sign = '='; - } else { - $sign = '!='; } - $value = trim(str_replace(['<', '=', '>', '!'], '', $value)); + $value = trim(str_replace(['<', '>'], '', $value)); if ($more || $minus) { $search_filters[] = 'CAST('.$search_query.' AS UNSIGNED) '.$sign.' '.prepare($value); } else { $search_filters[] = $search_query.' '.$sign.' '.prepare($value); } + + } else if ($equal){ + $value = trim(str_replace(['='], '', $value)); + $search_filters[] = ($search_query.' = '.prepare($value). ' OR '.$search_query.' LIKE '.prepare('% '.$value) . ' OR '.$search_query.' LIKE '.prepare($value.' %').' OR '.$search_query.' LIKE '.prepare('% '.$value.' %')); + } else if ($notequal) { + $value = trim(str_replace(['!='], '', $value)); + $search_filters[] = ($search_query.' != '.prepare($value). ' AND '.$search_query.' NOT LIKE '.prepare('% '.$value) . ' AND '.$search_query.' NOT LIKE '.prepare($value.' %').' AND '.$search_query.' NOT LIKE '.prepare('% '.$value.' %')); } else { $search_filters[] = $search_query.' LIKE '.prepare('%'.$value.'%'); }