Codeigniter not accepting "utf8mb4" as default charset Codeigniter not accepting "utf8mb4" as default charset codeigniter codeigniter

Codeigniter not accepting "utf8mb4" as default charset


In database.php

Set char_set to utf8mb4 and dbcollat to utf8mb4_unicode_ci or utf8_general_ci


I tested this with my Codeigniter 3.0

$db['default'] = array(    'dbdriver' => 'mysqli',    'dbprefix' => '',    'pconnect' => FALSE,    'db_debug' => (ENVIRONMENT !== 'production'),    'cache_on' => FALSE,    'cachedir' => '',    'char_set' => 'utf8mb4',    'dbcollat' => 'utf8mb4_unicode_ci',);

And in controller I add this

$CI = &get_instance();$CI->load->database();echo $CI->db->char_set;echo "<br>";echo $CI->db->dbcollat;

Output

utf8mb4utf8mb4_unicode_ci

Read this

  1. Using utf8mb4 with php and mysql


I was able to remove the bug by removing my php installation and installing the httpd and php again from scratch.