PHP开发实例大全(提高卷) 中文完整pdf扫描版[244MB]
找到config/main.php
- 'db'=>array(
- 'connectionString' => 'mysql:host=localhost;dbname=db1',
- 'emulatePrepare' => true,
- 'username' => 'root',
- 'password' => '',
- 'charset' => 'utf8',
- ),
第二个数据库配置
- 'db2'=>array(
- 'class'=>'CDbConnection',
- 'connectionString' => 'mysql:host=localhost;dbname=db2',
- 'emulatePrepare' => true,
- 'username' => 'root',
- 'password' => '',
- 'charset' => 'utf8',
- ),
调用方法
- $db1Rows = Yii::app()->db->createCommand($sql)->queryAll();
- $db2Rows = Yii::app()->db2->createCommand($sql)->queryAll();
- $db3Rows = Yii::app()->db2->createCommand($sql)->queryAll();
转载请注明:谷谷点程序 » yii1配置多个数据库的方法