本文整理汇总了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;
}