繁体   English   中英

商标符号在MySQL Select查询中不起作用

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM