How to insert a text with special chars in mysql using codeigniter

孤人 提交于 2019-12-25 03:54:07

问题


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!


回答1:


You need to create the database using collation utf8_unicode_ci. Also for phpMyAdmin. After creating the database click on the operations tab at the bottom you can change the database to the utf8_unicode_ci. For more information Here




回答2:


Following points required for multilingual data insert:

  • 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';


来源:https://stackoverflow.com/questions/25472973/how-to-insert-a-text-with-special-chars-in-mysql-using-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!