From 42bb1eb9ea8d798c95dfcd46407c8b390837ec64 Mon Sep 17 00:00:00 2001 From: Jeremy Newman Date: Fri, 22 Feb 2008 14:35:54 -0600 Subject: [PATCH] =?UTF-8?q?disable=20fuzzy=20search=20for=20the=20time=20b?= =?UTF-8?q?eing=20as=20the=20query=20might=20be=20causing=20issues=20with?= =?UTF-8?q?=20mysql=20Patch=20Author:=20Alexander=20Nicolaysen=20S=C3=B8rn?= =?UTF-8?q?es=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/application_queue.php | 2 -- include/util.php | 67 ----------------------------------- 2 files changed, 69 deletions(-) diff --git a/include/application_queue.php b/include/application_queue.php index 5727a28..4a4d4bf 100644 --- a/include/application_queue.php +++ b/include/application_queue.php @@ -278,8 +278,6 @@ class application_queue { echo "Like matches\n"; $this->displayDuplicateTable(searchForApplication($this->oApp->sName)); - echo "
Fuzzy matches\n"; - $this->displayDuplicateTable(searchForApplicationFuzzy($this->oApp->sName, 60)); } function displayDuplicateTable($hResult) diff --git a/include/util.php b/include/util.php index 0822b3c..94da5f2 100644 --- a/include/util.php +++ b/include/util.php @@ -441,68 +441,6 @@ function searchForApplication($search_words) return $hResult; } -function searchForApplicationFuzzy($search_words, $minMatchingPercent) -{ - /* cleanup search words */ - $search_words = cleanupSearchWords($search_words); - - $foundAValue = false; - $excludeAppIdArray = array(); - $appIdArray = array(); - - /* add on all of the like matches that we can find */ - $hResult = searchForApplication($search_words); - while($oRow = query_fetch_object($hResult)) - { - array_push($excludeAppIdArray, $oRow->appId); - } - - /* add on all of the fuzzy matches we can find */ - $sQuery = "SELECT appName, appId FROM appFamily WHERE state = 'accepted'"; - foreach ($excludeAppIdArray as $key=>$value) - { - $sQuery.=" AND appId != '".query_escape_string($value)."'"; - } - $sQuery.=";"; - - /* capitalize the search words */ - $search_words = strtoupper($search_words); - - $hResult = query_appdb($sQuery); - while($oRow = query_fetch_object($hResult)) - { - $oRow->appName = strtoupper($oRow->appName); /* convert the appname to upper case */ - similar_text($oRow->appName, $search_words, $similarity_pst); - if(number_format($similarity_pst, 0) > $minMatchingPercent) - { - $foundAValue = true; - array_push($appIdArray, $oRow->appId); - } - } - - if($foundAValue == false) - return null; - - $sQuery = "SELECT * from appFamily WHERE "; - - $firstEntry = true; - foreach ($appIdArray as $key=>$value) - { - if($firstEntry == true) - { - $sQuery.="appId='".query_escape_string($value)."'"; - $firstEntry = false; - } else - { - $sQuery.=" OR appId='".query_escape_string($value)."'"; - } - } - $sQuery.=" ORDER BY appName;"; - - $hResult = query_appdb($sQuery); - return $hResult; -} - function outputSearchTableForhResult($search_words, $hResult) { if(($hResult == null) || (query_num_rows($hResult) == 0)) @@ -584,11 +522,6 @@ function perform_search_and_output_results($search_words) echo "
Like matches
"; $hResult = searchForApplication($search_words); outputSearchTableForhResult($search_words, $hResult); - - $minMatchingPercent = 60; - echo "
Fuzzy matches - minimum ".$minMatchingPercent."% match
"; - $hResult = searchForApplicationFuzzy($search_words, $minMatchingPercent); - outputSearchTableForhResult($search_words, $hResult); } function display_page_range($iCurrentPage=1, $iPageRange=1, $iTotalPages=1, $sLinkurl=NULL)