'db'=>array( 
        'class'=>'application.extensions.DbConnectionMan',//扩展路径 
        'connectionString' => 'mysql:host=192.168.1.128;dbname=db_xcpt',//主数据库 写 
        'emulatePrepare' => true, 
        'username' => 'root', 
        'password' => 'root', 
        'charset' => 'utf8', 
        'tablePrefix' => 'xcpt_', //表前缀 
        'enableSlave'=>true,//从数据库启用 
   'urgencyWrite'=>true,//紧急情况 主数据库无法连接 启用从数据库 写功能 
    'masterRead'=>true,//紧急情况 从数据库无法连接 启用主数据库 读功能 
        'slaves'=>array(//从数据库 
            array(   //slave1 
                'connectionString'=>'mysql:host=localhost;dbname=db_xcpt', 
                'emulatePrepare' => true, 
                'username'=>'root', 
                'password'=>'root', 
                'charset' => 'utf8', 
                'tablePrefix' => 'xcpt_', //表前缀 
            ), 
   array(   //slave2 
                'connectionString'=>'mysql:host=localhost;dbname=db_xcpt', 
                'emulatePrepare' => true, 
                'username'=>'root', 
                'password'=>'root', 
                'charset' => 'utf8', 
                'tablePrefix' => 'xcpt_', //表前缀 
            ), 
 
        ), 
),
Yii实现多数据库主从读写分离的方法(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/f44136189e8f88f7f1f443e8faa282ff.html
