From 504817d08f5e2336f7ac79f102a2577924ab1fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Tue, 8 Jul 2008 21:23:07 +0200 Subject: [PATCH] Find more duplicates in partial searches --- include/util.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/util.php b/include/util.php index fe80fc3..6fe6c1c 100644 --- a/include/util.php +++ b/include/util.php @@ -430,6 +430,8 @@ function searchForApplicationPartial($sSearchWords) $sSearchWords = cleanupSearchWords($sSearchWords); $aWords = explode(' ', $sSearchWords); $sSearchString = ''; + $sEnsureExactWord = ''; // Used to ensure we don't match partial words when prepending + // a wildcard to the search string for($i = 0; $i < sizeof($aWords); $i++) { @@ -439,13 +441,13 @@ function searchForApplicationPartial($sSearchWords) if(strlen($aWords[$i]) > 4) { if($i < (sizeof($aWords) - 1)) - $sSearchString .= ' '; + $sEnsureExactWord = ' '; break; } } $hResult = query_parameters("SELECT * FROM appFamily WHERE state = 'accepted' AND - appName LIKE '?%'", $sSearchString); + (appName LIKE '?%' OR appName LIKE '?')", $sSearchString.$sEnsureExactWord, $sSearchString); return $hResult; }