From b6aac0beacdacf5d8a758737a614ba44c9ea3dc3 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 21 Dec 2017 14:06:46 +0900 Subject: [PATCH] Use 'equal' not 'like' for searches on user_id, user_name, nick_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit user_id, user_name, nick_name 검색에는 like가 아닌 equal 조건을 사용하도록 변경함. 이름이나 닉네임으로 검색할 때 LIKE %검색어% 문법이 사용되어 검색 속도가 느려지는 것은 물론, 특정 회원의 작성글 보기 메뉴를 클릭하면 검색어가 포함된 닉네임을 가진 다른 회원의 글까지 모두 표시되어 닉네임을 변경했거나 다중아이디를 사용하는 것으로 오해받는 문제를 수정함. (예: '라이믹스' 닉네임을 검색하면 '라이믹스최고' 회원의 글도 검색되었음) --- modules/comment/comment.model.php | 12 ++++++------ .../queries/getTotalCommentCountByGroupStatus.xml | 4 ++-- ...getTotalCommentCountWithinMemberByGroupStatus.xml | 6 +++--- modules/comment/queries/getTotalCommentList.xml | 4 ++-- .../queries/getTotalCommentListWithinMember.xml | 6 +++--- modules/document/document.model.php | 5 ++++- modules/document/queries/getDocumentCount.xml | 6 +++--- .../queries/getDocumentCountByGroupStatus.xml | 6 +++--- modules/document/queries/getDocumentList.xml | 6 +++--- .../document/queries/getDocumentListExtraSort.xml | 6 +++--- modules/document/queries/getDocumentListPage.xml | 6 +++--- modules/document/queries/getDocumentListUseIndex.xml | 6 +++--- .../getDocumentListWithinExtraVarsExtraSort.xml | 6 +++--- .../document/queries/getDocumentListWithinMember.xml | 6 +++--- 14 files changed, 44 insertions(+), 41 deletions(-) diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index ab8b9fdaa..7d27d1527 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -732,7 +732,7 @@ class commentModel extends comment case 'user_id' : if($search_keyword) { - $search_keyword = str_replace(' ', '%', $search_keyword); + $search_keyword = trim($search_keyword); } $args->s_user_id = $search_keyword; @@ -743,7 +743,7 @@ class commentModel extends comment case 'user_name' : if($search_keyword) { - $search_keyword = str_replace(' ', '%', $search_keyword); + $search_keyword = trim($search_keyword); } $args->s_user_name = $search_keyword; @@ -752,7 +752,7 @@ class commentModel extends comment case 'nick_name' : if($search_keyword) { - $search_keyword = str_replace(' ', '%', $search_keyword); + $search_keyword = trim($search_keyword); } $args->s_nick_name = $search_keyword; @@ -869,7 +869,7 @@ class commentModel extends comment case 'user_id' : if($search_keyword) { - $search_keyword = str_replace(' ', '%', $search_keyword); + $search_keyword = trim($search_keyword); } $args->s_user_id = $search_keyword; @@ -879,7 +879,7 @@ class commentModel extends comment case 'user_name' : if($search_keyword) { - $search_keyword = str_replace(' ', '%', $search_keyword); + $search_keyword = trim($search_keyword); } $args->s_user_name = $search_keyword; @@ -888,7 +888,7 @@ class commentModel extends comment case 'nick_name' : if($search_keyword) { - $search_keyword = str_replace(' ', '%', $search_keyword); + $search_keyword = trim($search_keyword); } $args->s_nick_name = $search_keyword; diff --git a/modules/comment/queries/getTotalCommentCountByGroupStatus.xml b/modules/comment/queries/getTotalCommentCountByGroupStatus.xml index a93002dea..c9a3f8f9b 100644 --- a/modules/comment/queries/getTotalCommentCountByGroupStatus.xml +++ b/modules/comment/queries/getTotalCommentCountByGroupStatus.xml @@ -12,8 +12,8 @@ - - + + diff --git a/modules/comment/queries/getTotalCommentCountWithinMemberByGroupStatus.xml b/modules/comment/queries/getTotalCommentCountWithinMemberByGroupStatus.xml index 19b345da2..1e6257bdd 100644 --- a/modules/comment/queries/getTotalCommentCountWithinMemberByGroupStatus.xml +++ b/modules/comment/queries/getTotalCommentCountWithinMemberByGroupStatus.xml @@ -8,13 +8,13 @@ - + - - + + diff --git a/modules/comment/queries/getTotalCommentList.xml b/modules/comment/queries/getTotalCommentList.xml index 3a201e9e6..22a684467 100644 --- a/modules/comment/queries/getTotalCommentList.xml +++ b/modules/comment/queries/getTotalCommentList.xml @@ -12,8 +12,8 @@ - - + + diff --git a/modules/comment/queries/getTotalCommentListWithinMember.xml b/modules/comment/queries/getTotalCommentListWithinMember.xml index 4bc79087f..90ebfa346 100644 --- a/modules/comment/queries/getTotalCommentListWithinMember.xml +++ b/modules/comment/queries/getTotalCommentListWithinMember.xml @@ -7,13 +7,13 @@ - + - - + + diff --git a/modules/document/document.model.php b/modules/document/document.model.php index c775c36d0..6ca69671e 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -1397,12 +1397,15 @@ class documentModel extends document $use_division = true; break; case 'user_id' : - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); + if($search_keyword) $search_keyword = trim($search_keyword); $args->s_user_id = $search_keyword; $args->sort_index = 'documents.'.$args->sort_index; break; case 'user_name' : case 'nick_name' : + if($search_keyword) $search_keyword = trim($search_keyword); + $args->{"s_".$search_target} = $search_keyword; + break; case 'email_address' : case 'homepage' : if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); diff --git a/modules/document/queries/getDocumentCount.xml b/modules/document/queries/getDocumentCount.xml index 401f47a60..a33ce2773 100644 --- a/modules/document/queries/getDocumentCount.xml +++ b/modules/document/queries/getDocumentCount.xml @@ -15,9 +15,9 @@ - - - + + + diff --git a/modules/document/queries/getDocumentCountByGroupStatus.xml b/modules/document/queries/getDocumentCountByGroupStatus.xml index 94bcb1894..d2a470e5b 100644 --- a/modules/document/queries/getDocumentCountByGroupStatus.xml +++ b/modules/document/queries/getDocumentCountByGroupStatus.xml @@ -16,9 +16,9 @@ - - - + + + diff --git a/modules/document/queries/getDocumentList.xml b/modules/document/queries/getDocumentList.xml index 5919beab0..4d855e6ab 100644 --- a/modules/document/queries/getDocumentList.xml +++ b/modules/document/queries/getDocumentList.xml @@ -19,9 +19,9 @@ - - - + + + diff --git a/modules/document/queries/getDocumentListExtraSort.xml b/modules/document/queries/getDocumentListExtraSort.xml index e843f8900..f6f1bd149 100644 --- a/modules/document/queries/getDocumentListExtraSort.xml +++ b/modules/document/queries/getDocumentListExtraSort.xml @@ -23,9 +23,9 @@ - - - + + + diff --git a/modules/document/queries/getDocumentListPage.xml b/modules/document/queries/getDocumentListPage.xml index 2ad9dc683..e6b76d51f 100644 --- a/modules/document/queries/getDocumentListPage.xml +++ b/modules/document/queries/getDocumentListPage.xml @@ -19,9 +19,9 @@ - - - + + + diff --git a/modules/document/queries/getDocumentListUseIndex.xml b/modules/document/queries/getDocumentListUseIndex.xml index 4182a5ad0..dc8ed7963 100644 --- a/modules/document/queries/getDocumentListUseIndex.xml +++ b/modules/document/queries/getDocumentListUseIndex.xml @@ -22,9 +22,9 @@ - - - + + + diff --git a/modules/document/queries/getDocumentListWithinExtraVarsExtraSort.xml b/modules/document/queries/getDocumentListWithinExtraVarsExtraSort.xml index 6ab95e780..c1fe25612 100644 --- a/modules/document/queries/getDocumentListWithinExtraVarsExtraSort.xml +++ b/modules/document/queries/getDocumentListWithinExtraVarsExtraSort.xml @@ -24,9 +24,9 @@ - - - + + + diff --git a/modules/document/queries/getDocumentListWithinMember.xml b/modules/document/queries/getDocumentListWithinMember.xml index 49792e11d..9b8273b28 100644 --- a/modules/document/queries/getDocumentListWithinMember.xml +++ b/modules/document/queries/getDocumentListWithinMember.xml @@ -5,7 +5,7 @@ - + @@ -13,8 +13,8 @@ - - + +