简体   繁体   English

Laravel MySQL匹配不返回结果

[英]Laravel MySQL match against does not return results

Here is the controller : 这是控制器:

public function getSearch()
{   
    $search = e(Input::get('name'));
    $search = preg_replace('#[^a-z A-Z 0-9 ? !]#i',' ', $search);
    $query = "MATCH (name,description) AGAINST ('".$search."' IN BOOLEAN MODE)";
    $accounts = Account::whereRaw($query)->paginate(10);
    if ($accounts->count())
    {
        return View::make('accounts.all')->with('accounts',$accounts);
    }
    else
    {
        $accounts = Account::paginate(10);
        Session::flash('fail', 'Sorry, the search term - '.$search.' did not match any records');
        return View::make('accounts.all')->with('accounts',$accounts);
    }
}

So the controller executes the else statement, however there are no any errors. 因此,控制器执行else语句,但是没有任何错误。

This is the row query: 这是行查询:

SELECT * FROM `accounts`  WHERE MATCH(name,description) AGAINST('search word' IN BOOLEAN MODE)

解决了,我试图用一半的单词来搜索,但我不知道它必须是完整的单词才能被找到,谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM