Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
512 views
in Technique[技术] by (71.8m points)

php - 搭配MySQL与MySQL搭配使用的最佳排序规则是什么? [关闭](What is the best collation to use for MySQL with PHP? [closed])

I'm wondering if there is a "best" choice for collation in MySQL for a general website where you aren't 100% sure of what will be entered?

(我想知道对于一般网站而言,MySQL中是否存在“最佳”排序规则选择,您不确定100%确定要输入什么内容吗?)

I understand that all the encodings should be the same, such as MySQL, Apache, the HTML and anything inside PHP.

(我知道所有编码都应该相同,例如MySQL,Apache,HTML和PHP中的任何内容。)

In the past I have set PHP to output in "UTF-8", but which collation does this match in MySQL?

(过去,我已将PHP设置为在“ UTF-8”中输出,但是在MySQL中此匹配哪种排序规则?)

I'm thinking it's one of the UTF-8 ones, but I have used utf8_unicode_ci , utf8_general_ci , and utf8_bin before.

(我以为它是UTF-8的其中之一,但是我之前曾使用过utf8_unicode_ciutf8_general_ciutf8_bin 。)

  ask by Darryl Hein translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The main difference is sorting accuracy (when comparing characters in the language) and performance.

(主要区别是排序准确性(在比较语言中的字符时)和性能。)

The only special one is utf8_bin which is for comparing characters in binary format.

(唯一的特殊之处是utf8_bin,它用于比较二进制格式的字符。)

utf8_general_ci is somewhat faster than utf8_unicode_ci , but less accurate (for sorting).

(utf8_general_ciutf8_unicode_ci快一些,但准确性较低(用于排序)。)

The specific language utf8 encoding (such as utf8_swedish_ci ) contain additional language rules that make them the most accurate to sort for those languages.

(特定语言utf8编码 (例如utf8_swedish_ci )包含其他语言规则,这些规则使它们最准确地分类为这些语言。)

Most of the time I use utf8_unicode_ci (I prefer accuracy to small performance improvements), unless I have a good reason to prefer a specific language.

(大部分时间我都使用utf8_unicode_ci (我宁愿使用精度而不是小幅度的性能改进),除非我有充分的理由偏爱特定的语言。)

You can read more on specific unicode character sets on the MySQL manual - http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html

(您可以在MySQL手册( http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html)上阅读有关特定Unicode字符集的更多信息。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...