search collapsing whitespaces

This commit is contained in:
alejandro.campos@artica.es 2024-02-13 18:28:20 +01:00
parent 8422aba9d7
commit c7de5a1eba
1 changed files with 6 additions and 2 deletions

View File

@ -1177,14 +1177,18 @@ function events_get_all(
$array_search[] = 'lower(ta.alias)'; $array_search[] = 'lower(ta.alias)';
} }
// Disregard repeated whitespaces in search string.
$collapsed_spaces_search = preg_replace('/( )+/', ' ', $filter['search']);
$sql_search = ' AND ('; $sql_search = ' AND (';
foreach ($array_search as $key => $field) { foreach ($array_search as $key => $field) {
// Disregard repeated whitespaces in query searched string.
$sql_search .= sprintf( $sql_search .= sprintf(
'%s %s %s like lower("%%%s%%")', '%s REGEXP_REPLACE(%s, "( \\s*)+", " ") %s like lower("%%%s%%")',
($key === 0) ? '' : $nexo, ($key === 0) ? '' : $nexo,
$field, $field,
$not_search, $not_search,
$filter['search'] $collapsed_spaces_search
); );
$sql_search .= ' '; $sql_search .= ' ';
} }