I want to set the MySQL database connection to use utf8 encoding. So I
overide the App_Model constructor like this:
class AppModel extends Model {
function __construct()
{
$this->execute("Set NAMES 'UTF8'");
parent::__construct();
}
}
And then I got this error:
Fatal error: Call to a member function fetchAll() on a non-object in
D:\php-5.0.4-Win32\PHP_Script\PHP_CAKE\cake\libs\model\model_php5.php
on line 1143
But I add the execute statment in the other member function will be ok.
I think there is some object (maybe the database connection) hasn't
been created when the __construct() execute. Am I right? And How can I
slove this problem?