[英]Trade Mark symbol not working in MySQL Select Query
MySQL和Codeigniter中的以下查詢給我一個錯誤。
SELECT * FROM table where name='hellome� test'
錯誤:
#1267 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
and (utf8mb4_general_ci,COERCIBLE) for operation '='
Codeigniter中也出現此錯誤。
題
如何在MySQL查詢中允許這種類型的字符。
您應該在config> database.php內將數據庫字符編碼設置為以下行。 “ utf8”是您的數據庫字符編碼。
$db ['default'] = array (
'dsn' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array (),
'save_queries' => TRUE
);
使用活動記錄。
$this->db->select('*');
$this->db->from('blogs');
$this->db->where('name','hellome� test');
這很可能是因為您的表和數據庫模式位於拉丁語中。 嘗試運行以下命令:
ALTER DATABASE db CHARACTER SET utf8 COLLATE utf8_general_ci
ALTER TABLE table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.