[英]Illegal mix of collations PHP MYSQL, latin1_swedish_ci and utf8_general_ci
[英]MySQLiQuery_Exception' with message 'Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) - with PHP5
我有這個錯誤:
Fatal error: Uncaught exception 'MySQLiQuery_Exception' with message 'Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=': select id from 'addresses' where 'shiptozip'='13000' and 'shiptostreet'='Františka Křížka'
如您所見,我正在嘗試從表地址中獲取ID。
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
其中表“ addresses”還具有utf8_general_ci
和utf8
。 我想這與查詢FrantiškaKřížka有關,因為其他查詢也可以。 server_collation以前是latin_swedish_ci
但我想我現在已經設法全部更改了(如上表所示)。 提前致謝。
您可以在問題中附加以下項的“ shiptoaddress”和“ shiptozip”列的排序規則嗎?
SHOW FULL COLUMNS FROM addresses;
根據您提供的證據,可能發生的情況是“ shiptoaddress”列仍具有latin1編碼。 設置表的編碼/排序規則時,您將設置默認值。 可以為單個列覆蓋此默認值。
如果查詢適用於where address = 'Frank'
但不適用於where address = 'Františka'
,那是因為“Františka”無法轉換為latin1。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.