当我从数据库中获取对象并运行 Zend 魔法函数时 -> Order (),或作为普通 SQL,例如 title,以及那些包含瑞典语字符 åäö 的内容,因此将它们解释为 aao。它的排序错误,不是 a 就是 o,而实际上它应该放在最后。
有人知道如何解决这个问题吗?看起来像个白痴,却没有任何结果。
编辑:数据库的排序规则为utf8_unicode_ci,编码为utf8。我尝试更改为 utf8_swedish_ci 但没有成功。恐怕我需要保留 utf8 或者我没有任何选择吗?
When I pick up objects from the database and run the Zend magic function -> Order (), or as plain SQL, for example, title, and those containing Swedish characters as åäö so interpreted them as aao. It comes with the wrong sort, either a or o when it really should be ordered last.
Anyone got a clue how to solve this? Have looked like an idiot with no result.
Edit: The collation of the database is utf8_unicode_ci and the encoding is utf8. I have tried to change to utf8_swedish_ci but with no success. And I'm afraid I need to have the utf8 left or do I not any choice there?
发布评论
评论(1)
您的 MySQL 数据库是否设置为使用正确的排序规则?我认为默认情况下它设置为瑞典语排序规则
latin1_swedish_ci
:http://dev.mysql.com/doc/refman/5.5/en/charset-we-sets.html但是如果它被更改为其他内容(例如
latin1< /code>) 它可能会对重音字符进行不同的排序。
这里有关于如何指定特定数据库、列或表使用哪种排序规则的说明:
http://dev.mysql.com/doc/refman/5.0/en/charset-syntax.html
编辑: 瑞典语排序规则就是您想要的:http://www.collation-charts.org/mysql60/mysql604.latin1_swedish_ci。 html 但您可能使用通用的: http://www .collation-charts.org/mysql60/mysql604.latin1_general_ci.html
Is your MySQL database set up to use the proper collation? I think by default it's set to the Swedish collation
latin1_swedish_ci
: http://dev.mysql.com/doc/refman/5.5/en/charset-we-sets.htmlBut if it's been changed to something else (like
latin1
) it might order the accented characters differently.There are instructions on how to specify which collation to use for a particular DB, column, or table here:
http://dev.mysql.com/doc/refman/5.0/en/charset-syntax.html
Edit: The Swedish collation is what you want: http://www.collation-charts.org/mysql60/mysql604.latin1_swedish_ci.html but you are likely using the general one: http://www.collation-charts.org/mysql60/mysql604.latin1_general_ci.html