php – 使用laravel elequent在MySQL中搜索波斯语字符串

php – 使用laravel elequent在MySQL中搜索波斯语字符串,第1张

概述在我的laravel中,为了搜索产品标题列,我使用以下代码: $products->where('title', 'like', '%' . $request->title . '%'); title列是一个字符串列,存储在其中的数据是波斯语.此外,数据库排序规则是UTF8_general_ci.然而,当我搜索某些标题时,有些标题没有.我需要结果来查找标题列中包含$request->标题的每个产品 在我的laravel中,为了搜索产品标题列,我使用以下代码:

$products->where('Title','like','%' . $request->Title . '%');

Title列是一个字符串列,存储在其中的数据是波斯语.此外,数据库排序规则是UTF8_general_ci.然而,当我搜索某些标题时,有些标题没有.我需要结果来查找标题列中包含$request->标题的每个产品.

你能帮助我吗?

解决方法 将归类UTF8_general_ci更改为latin1_swedish_ci

Collations have these general characteristics:

Two different character sets cannot have the same collation.

Each character set has one collation that is the default collation. For example,the default collation for latin1 is latin1_swedish_ci. The output for SHOW CHaraCTER SET indicates which collation is the default for each displayed character set.

There is a convention for collation names: They start with the name of the character set with which they are associated,they usually include a language name,and they end with _ci (case insensitive),_cs (case sensitive),or _bin (binary).

In cases where a character set has multiple collations,it might not be clear which collation is most suitable for a given application. To avoID choosing the wrong collation,it can be helpful to perform some comparisons with representative data values to make sure that a given collation sorts values the way you expect.

参考here

总结

以上是内存溢出为你收集整理的php – 使用laravel elequent在MySQL中搜索波斯语字符串全部内容,希望文章能够帮你解决php – 使用laravel elequent在MySQL中搜索波斯语字符串所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1253646.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存