From: eileen Date: Thu, 23 Jun 2016 03:17:50 +0000 (+1200) Subject: CRM-18694 alternative solution to easier post code searching. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=12af7addc319da3b5cb4555787d8a1b1bd7efa12;p=civicrm-core.git CRM-18694 alternative solution to easier post code searching. The proposal is to change it to regex but the comments suggest the primary reason for this is that it makes more sense to search from the start of the string. This being the case it seems that we could opt to use an indexed query rather than regex --- diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 2da17695ea..f6e17e8eb4 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -688,7 +688,9 @@ LIMIT {$offset}, {$rowCount} foreach ($mappings as $key => $dbName) { if (!empty($searchParams[$key])) { - $queryParams[$nextParamKey] = array('%' . $searchParams[$key] . '%', 'String'); + // CRM-18694. + $wildcard = strstr($key, 'postcode') ? '' : '%'; + $queryParams[$nextParamKey] = array($wildcard . $searchParams[$key] . '%', 'String'); $where[] = $dbName . " LIKE %{$nextParamKey} "; $nextParamKey++; }