如何使用codeigniter在mysql中插入带有特殊字符的文本 [英] How to insert a text with special chars in mysql using codeigniter

查看:171
本文介绍了如何使用codeigniter在mysql中插入带有特殊字符的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在mysql数据库中插入一个包含特殊字符的文本(例如:'é')
文本被插入,'é'被替换为'?'
i am using codeigniter active记录

I am trying to insert a text in mysql database that contains special chars (example : 'é' ) the text is inserted and 'é' is replaced with '?' i am using codeigniter active record

任何人都可以向我解释如何做到这一点?
提前感谢!

Can anyone explain to me how to do that? Thanks in advance!

推荐答案

多语言数据所需的以下几点:

Following points required for multilingual data insert:


  • 使用集合utf8_unicode_ci创建数据库。

  • 创建您的数据库表,并确保您已选择/写入集合设置为

  • 现在来到codeigniter部分,并检查您的数据库配置文件的位置如下所述

  • Create your database with collection "utf8_unicode_ci". Basically this allows Unicode (multilingual), case-insensitive data to be saved in your database.
  • Create your database table and make sure you have selected/written collection set to be "utf8_unicode_ci" for all the table fields.
  • Now comes to codeigniter part and check your database config file with location as mentioned below

application / config / database.php

检查&更新字符集

Now please check & update charset & collection settings as mentioned below

$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';

这篇关于如何使用codeigniter在mysql中插入带有特殊字符的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆