diff Keyword.class.php @ 130:290a05fd7331

mod: 半角英数で検索しても全角英数がヒットするように変更
author Sushi-k <epgrec@park.mda.or.jp>
date Thu, 18 Mar 2010 17:50:01 +0900
parents 7a64d5e3baee
children 9c5e597ef6c6
line wrap: on
line diff
--- a/Keyword.class.php	Wed Mar 17 20:39:36 2010 +0900
+++ b/Keyword.class.php	Thu Mar 18 17:50:01 2010 +0900
@@ -36,7 +36,23 @@
 				$options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($keyword)."'";
 			}
 			else {
-				$options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($keyword)."%'";
+				// 茹茹
+				// 翫絲上
+				$f_zennum = preg_match('/[0-9]/u', $keyword );
+				$f_zenal  = preg_match('/[a-zA-Z]/u', $keyword );
+				
+				$options .= " AND ( CONCAT(title,' ',description) like '%".mysql_real_escape_string($keyword)."%'";
+				
+				if( $f_zennum ) {
+					$options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVN' ))."%'";
+				}
+				if( $f_zenal ) {
+					$options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVR' ))."%'";
+				}
+				if( $f_zenal && $f_zennum ) {
+					$options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVRN' ))."%'";
+				}
+				$options .= ") ";
 			}
 		}
 		
@@ -163,4 +179,4 @@
 		parent::__destruct();
 	}
 }
-?>
\ No newline at end of file
+?>