我想知道我怎么能忽略口音在多重搜索和雄辩从拉拉维尔。
目前,我有以下几点:
// $searchTerms => 'Héllo human';
$explodedTerms = explode(" ", $searchTerms);
...
// $explodedTerms => ['Héllo', 'human'];
$query->where(function ($q) use ($explodedTerms) {
foreach ($explodedTerms as $value) {
$q->whereRaw('LOWER(`text`) LIKE ?', ['%'.strtolower($value).'%' ]);
}
});
...我想让搜索词'hello human‘来匹配字段文本。
我试过用ILIKE,但我有个错误:
$q->whereRaw('LOWER(`text`) ILIKE ?', ['%'.strtolower($value).'%' ]);SQLSTATE42000:语法错误或访问冲突: 1064您的SQL语法出现了错误;请检查与MySQL服务器版本对应的手册,以获得在ILIKE附近使用的正确语法。
发布于 2019-05-22 09:35:49
这是答案$str = iconv('utf-8',‘ASCII//忽略’,$str);
https://stackoverflow.com/questions/56253145
复制相似问题