本文整理匯總了PHP中SearchEngine::prepareWords方法的典型用法代碼示例。如果您正苦於以下問題:PHP SearchEngine::prepareWords方法的具體用法?PHP SearchEngine::prepareWords怎麽用?PHP SearchEngine::prepareWords使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SearchEngine
的用法示例。
在下文中一共展示了SearchEngine::prepareWords方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getQueryChannels
static function getQueryChannels($words){
$user=$_SESSION['user'];
$_anon=($user->isAnon())?'true':'false';
$words=SearchEngine::prepareWords($words);
$ORDERBY='S.haslogo desc, S.qt_followers desc';
$query = "SELECT *,((CASE haslogo WHEN 'true' THEN 1 ELSE 0 END)*100+qt_followers*random()) as QUERY_rank FROM vw_channel as S WHERE (1=1";
for ($i=0;$i<sizeof($words);$i++){
switch ($words[$i]){
case '[mychannels]':
if (!$user->isAnon())
$query.=" AND userid='{$user->getId()}'";
break;
case '[signedchannels]':
$query.=" AND S.id in (SELECT channelid from follow_channel_user WHERE userid='{$user->getId()}' and anon='{$_anon}')";
break;
case '[suggestchannels]':
$_anon= ($user->isAnon())?'true':'false';
$addwhere='';if (!($user->isAnon())) $addwhere.=" and userid!='{$user->getId()}'";
$query.=" AND S.id not in (select channelid from follow_channel_user where userid='{$user->getId()}' and anon='{$_anon}') {$addwhere} ";
$ORDERBY='QUERY_rank desc';
break;
default:
$query.=" AND (lower(S.pp_name) like lower('%".$words[$i]."%') OR lower(S.pp_description) like lower('%".$words[$i]."%') )";
break;
}
}
$query.=") ORDER BY {$ORDERBY}";
return $query;
}