yii php Mon Oct 10 06:29:30 -0400 2011

Subject: UTF8 is not work fine

hello
when i use chinese,it is show messy code in mysql

code snippet that re-creates the problem
in mysql it is show 测试 . it is bad. messy code in mysql

table schema

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(30) NOT NULL,
  `password` varchar(64) NOT NULL,
  `salt` varchar(100) NOT NULL,
  `created` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `email`, `password`, `salt`, `created`) VALUES
(1, '11', '测试', '', 0);

PHP version 5.3
database version 5.1.6

 require_once dirname(__FILE__) . '/core/php-activerecord/ActiveRecord.php';

 $connections = array(
    'development' => 'mysql://test:test@localhost/app',
    'production' => 'mysql://test:test@localhost/app;charset=utf8',
    'test' => 'mysql://test:test@localhost/app?charset=utf8'
 );  
 ActiveRecord\Config::initialize(function($cfg) use ($connections)
 {
   $cfg->set_model_directory(dirname(__FILE__) . '/src/models');
   $cfg->set_connections($connections); 
   $cfg->set_default_connection('production');

 });

 $user = User::create(array('email' => '11', 'password' => '测试'));