【问题标题】:Laravel MySQL match against does not return resultsLaravel MySQL 匹配不返回结果
【发布时间】:2015-10-01 21:32:25
【问题描述】:

这里是控制器:

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);
    }
}

所以控制器执行了else语句,但是没有任何错误。

这是行查询:

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

【问题讨论】:

  • 显示 $accounts 的转储。 dd($accounts);
  • 嗨,它解决了我试图使用半个单词进行搜索,但我不知道它需要是完整的单词才能找到,谢谢

标签: php mysql laravel match match-against


【解决方案1】:

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

【讨论】:

  • 即使你解决了这个问题,你也可以使用this
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-25
  • 1970-01-01
  • 2016-05-17
  • 2021-08-06
  • 1970-01-01
  • 2017-01-28
相关资源
最近更新 更多