MySQL Show相关查询无法正常工作

时间:2017-02-08 06:43:36

标签: php mysql

我有一个查询,根据我正在播放的标题和标签显示当前视频的相关视频。事情是,即使名称完全相同,它也不会真正显示相关视频。

这是代码和查询。

$pieces = array_filter(explode(" ", removeCommonWords(str_replace(array('(', ')'), '', $video->title))));
$pieces2 = array_filter(explode(",", removeCommonWords(str_replace(array('(', ')'), '', $video->tags))));
$pieces = array_merge($pieces, $pieces2);
$par = array();
$par[] = removeCommonWords(str_replace(array('(', ')'), '', $video->title));
foreach($pieces as $p) {
    if (strlen($p) > 2) {
        if (strlen($p) < 4) {
            $par[] = $p.
            '*';
        } else {
            $par[] = $p;
        }
    }
}
$key = toDb(implode(",", $par));
$options = DB_PREFIX.
"videos.id as vid,".DB_PREFIX.
"videos.title,".DB_PREFIX.
"videos.user_id as owner,".DB_PREFIX.
"videos.thumb,".DB_PREFIX.
"videos.views,".DB_PREFIX.
"videos.duration";
$vq = "select ".$options.
", ".DB_PREFIX.
"users.name ,
MATCH(title, description, tags) AGAINST('".$key."'
        IN BOOLEAN MODE) AS relevance,
    MATCH(title) AGAINST('".$key."'
        IN BOOLEAN MODE) AS title_relevance FROM ".DB_PREFIX."
videos LEFT JOIN ".DB_PREFIX."
users ON ".DB_PREFIX."
videos.user_id = ".DB_PREFIX."
users.id
WHERE MATCH(title, description, tags) AGAINST('".$key."'
    IN BOOLEAN MODE) AND ".DB_PREFIX."
videos.pub > 0 ORDER by title_relevance DESC, relevance DESC limit 1, ".get_option('related-nr',12)."
";
$result = $cachedb->get_results($vq);

我有什么遗失的吗?

0 个答案:

没有答案