Change database encoding in codeigniter


mysql_query('SET NAMES `utf8`;', $link);

is the same that

$db['default']['char_set'] = 'utf8';


$db['default']['dbcollat'] = 'utf8_general_ci';

in “application\config\database.php” on Codeigniter? If not, how can I do it in Codeigniter?

CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.). The config file is located at application/config/database.php. You can also set database connection values for specific environments by placing database.php it the respective environment config folder.

More on this page:

Place a database.php in your application/config folder and edit the file to suit your needs.