Codeigniter not accepting "utf8mb4" as default charset
In database.php
Set
char_set
toutf8mb4
anddbcollat
toutf8mb4_unicode_ci
orutf8_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
I was able to remove the bug by removing my php installation and installing the httpd and php again from scratch.