阅读:1591回复:4
mysql搜索问题
按照昨天一个帖子里面的方法改了一下只搜索别名 名称 演员,但是查看到mysql慢日记里面还有查询好几项内容的搜索,不知道是哪里的,,特来问下...
select m.*,0,0 from sea_data m where m.v_recycled=0 and (m.v_name like '%聊斋%' or m.v_actor like '%聊斋%' or m.v_director like '%聊斋%' or m.v_publisharea like '%聊斋%' or m.v_nickname like '%聊斋%' or m.v_publishyear like '%聊斋%' or m.v_letter='聊斋' or m.v_tags='聊斋') order by m.v_addtime desc limit 50,10; search.php修改的如下,因为我是9.99版本,没法直接升级10.2 switch (intval($searchtype)) { case -1: $whereStr=" where v_recycled=0 and (v_name like '%$searchword%' or v_actor like '%$searchword%' or v_nickname like '%$searchword%')"; break; case 0: $whereStr=" where v_recycled=0 and v_name like '%$searchword%'"; break; case 1: $whereStr=" where v_recycled=0"; if(!empty($tid)) $whereStr.=" and (tid in (".getTypeId($tid).") or FIND_IN_SET('".$tid."',v_extratype)<>0)"; if($year=="more") { $publishyeartxt=sea_DATA."/admin/publishyear.txt"; $publishyear = array(); if(filesize($publishyeartxt)>0) { $publishyear = file($publishyeartxt); } $yearArray=$publishyear; $yeartxt= implode(',',$yearArray); $whereStr.=" and v_publishyear not in ($yeartxt)"; } if(!empty($year) AND $year!="more") {$whereStr.=" and v_publishyear='$year'";} if($letter=="0-9") {$whereStr.=" and v_letter in ('0','1','2','3','4','5','6','7','8','9')";} if(!empty($letter) AND $letter!="0-9") {$whereStr.=" and v_letter='$letter'";} if(!empty($area)) $whereStr.=" and v_publisharea='$area'"; if(!empty($yuyan)) $whereStr.=" and v_lang='$yuyan'"; if(!empty($jq)) $whereStr.=" and v_jq like'%$jq%'"; if($state=='l') $whereStr.=" and v_state !=0"; if($state=='w') $whereStr.=" and v_state=0"; if($money=='s') $whereStr.=" and v_money !=0"; if($money=='m') $whereStr.=" and v_money=0"; if(!empty($ver)) $whereStr.=" and v_ver='$ver'"; break; } |
|
2楼#
发布于:2020-10-25 23:29
感谢!请问是1900行这个代码吗,测试成功了。case -1修改了,case1-case4我删除掉了(这个不知道具体的作用是什么?不是直接用的是case -1吗?)。 case "search" : global $searchtype, $searchword; switch (intval ( $searchtype )) { case - 1 : $whereStr = " where m.v_recycled=0 and (m.v_name like '%$searchword%' or m.v_actor like '%$searchword%' or m.v_nickname like '%$searchword%')"; break; case 0 : $whereStr = " where m.v_recycled=0 and m.v_name like '%$searchword%'"; break; } break; |
|
4楼#
发布于:2020-10-26 14:23
这个有办法改成索引搜索吗?试了一下发现type是all。
|
|