Skip to content

Instantly share code, notes, and snippets.

@jjjjcccjjf
Last active September 14, 2018 08:23
Show Gist options
  • Save jjjjcccjjf/4c0801c9e678c4544a5550e8ff9d5bde to your computer and use it in GitHub Desktop.
Save jjjjcccjjf/4c0801c9e678c4544a5550e8ff9d5bde to your computer and use it in GitHub Desktop.
Working with Emojis [MySQL GUIDE]

How to enable emojis in MySQL database

TLDR:

If you are using CodeIgniter

  • Set the character set into utf8mb4 and DB collation to utf8mb4_bin
  • Or you can just edit application/config/database.php like this
$db['default'] = array(
  # ...
  'char_set' => 'utf8mb4',
  'dbcollat' => 'utf8mb4_bin',
  # ...
);

If you are using DBForge Migrations

$this->dbforge->create_table('messages', FALSE, array('CHARACTER SET' => 'utf8mb4', 'COLLATE' => 'utf8mb4_bin'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment