问题
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