How to store emoji in database😀
Generally, when you insert emoji into the database it will show as ????, so to fix the issue follow the below steps
Step 1 (For Codeigniter application only):
In application/config/database.php change the values of the following variables:
$db['default']['char_set'] = 'utf8mb4'; $db['default']['dbcollat'] = 'utf8mb4_unicode_ci';
Step 2:
Execute the following query in whichever database you want to store emoji:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
Step 3:
Execute the following query in whichever table you want to store emoji:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
That's it, you're done, now try to insert emoji and check!
Tagged: