Codeigniter: Cannot retrieve saved emoji from mysql

Created on 23 Apr 2017  路  4Comments  路  Source: bcit-ci/CodeIgniter

I could be able to save emoji into mysql with utf8mb4_unicode_ci collation. (Also can see in phpmyadmin). But when I run a query with php (Codeigniter), I get a single question mark (?) instead of emoji. Any idea?

emoji

My query:

$query = $this->db->query("SELECT * FROM emoji");

Or even:

$query = $this->db->query("SET character_set_client=utf8mb4");
$query = $this->db->query("SELECT * FROM emoji");

Any idea?

Most helpful comment

Please note that this is a bug tracker and in the future, post your questions on our forums instead.

All 4 comments

I forgot to add these two lines:

$query = $this->db->query("SET character_set_connection=utf8mb4");
$query = $this->db->query("SET character_set_results=utf8mb4");

Now, it works fine.

Please note that this is a bug tracker and in the future, post your questions on our forums instead.

Btw why do you change the character set manually instead setting in the config?

@AdaLiszk That's a good idea. I'm going to try.
Thanks.

Was this page helpful?
0 / 5 - 0 ratings