gpt4 book ai didi

php - 忽略多个搜索请求中的重音

转载 作者:行者123 更新时间:2023-11-29 16:00:07 25 4
gpt4 key购买 nike

我想知道如何使用 Laravel 中的 eloquent 忽略多重搜索中的重音。

目前我有这个:

// $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).'%' ]);

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ILIKE

最佳答案

这就是答案$str = iconv('utf-8','ASCII//IGNORE',$str);

关于php - 忽略多个搜索请求中的重音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56253145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com