Using UTF-8 as encoding for the database connection

Published on and tagged with cakephp  database  mysql  tip

I already wrote about this topic some time ago. In that post I described an approach using the configuration file of MySQL, and mentioned casually that you could execute “SET NAMES utf8” if you do not have access to the MySQL configuration file. But I did not show a solution for that case…

Well, today I saw a solution, presented by nate in a post in the google group:

// app/app_model.php
class AppModel extends Model 
    function __construct() 
        $this->execute("Set NAMES 'UTF8'"); 

2 comments baked

© daniel hofstetter. Licensed under a Creative Commons License