yg 2016-04-01 17:01:02 5396次浏览 3条回复 0 1 0

yii1.1版本的 mysql主从数据库配置 我用的是AR操作的数据库 怎么实现读写分离 我这图就是yii配置文件里 配的数据库

觉得很赞
  • 回复于 2016-04-03 13:39 举报

    我记得是直接用config来实现的,不需要在AR层做修改。

    1 条回复
    回复于 2016-04-05 14:43 回复

    我在配置文件里配的 但是不起作用,并且程序访问不到数据库了

    'db'=>array(
            'class'=>'DbConnectionMan',//Specify it,instead of CDbConnection,other options is same as CDbConnection
            'connectionString' => 'mysql:host=192.168.207.132:3306;dbname=eyisheng',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '123456',
            'charset' => 'utf8',
            'tablePrefix' => 'dv_',
            'enableSlave'=>true,//Read write splitting function is swithable.You can specify this value to false to disable it.
            'slaves'=>array(//slave connection config is same as CDbConnection
                array(
                    'connectionString'=>'mysql:host=192.168.207.133:3306;dbname=eyisheng',
                    'username'=>'root',
                    'password'=>'123456',
                     'tablePrefix' => 'dv_',
                )
            ),
        ),
    
  • 回复于 2016-04-04 10:30 举报

    截图看一下呗

  • 回复于 2016-04-05 14:42 举报
    'db'=>array(
            'class'=>'DbConnectionMan',//Specify it,instead of CDbConnection,other options is same as CDbConnection
            'connectionString' => 'mysql:host=192.168.207.132:3306;dbname=eyisheng',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '123456',
            'charset' => 'utf8',
            'tablePrefix' => 'dv_',
            'enableSlave'=>true,//Read write splitting function is swithable.You can specify this value to false to disable it.
            'slaves'=>array(//slave connection config is same as CDbConnection
                array(
                    'connectionString'=>'mysql:host=192.168.207.133:3306;dbname=eyisheng',
                    'username'=>'root',
                    'password'=>'123456',
                     'tablePrefix' => 'dv_',
                )
            ),
        ),
    
    1 条回复
    回复于 2021-10-19 10:55 回复

    您好,请问解决了吗?我现在也出现同样问题了

您需要登录后才可以回复。登录 | 立即注册