YII如何同时访问不同的数据库,比如mysql 和 memcachedb

YII如何同时访问不同的数据库,比如mysql 和 memcachedb

如何封装memcachedb和mysql,写个基类?!

访问多个数据库可以配置多个组件啊 你看http://www.yiiframework.net/index.php/post/37/多数据库操作#c82能帮你不

不行啊,如下配置:

‘components’=>array(

	'user'=>array(


		// enable cookie-based authentication


		'allowAutoLogin'=>true,


	),


	'db'=>array(


		'connectionString' => 'sqlite:protected/data/testdrive.db',


	),


	// uncomment the following to use a MySQL database


	


	'db1'=>array(


		'connectionString' => 'mysql:host=localhost;dbname=abc,


		'emulatePrepare' => true,


		'username' => 'abc',


		'password' => '123456,


		'charset' => 'utf8',


	),

报错: Yii::app()->db1;

CException

Description

Object configuration must be an array containing a "class" element.

/data1/sinawap/code/run/htdocs/prog/testdrive/protected/controllers/Tbl_userController.php(126)

00126: $db1 =Yii::app()->db1;

可以了:

配置成这样:

‘db1’=>array(

                    'class'=>'system.db.CDbConnection',


		'connectionString' => 'mysql:host=localhost;dbname=abc,


		'emulatePrepare' => true,


		'username' => 'abc',


		'password' => '123456,


		'charset' => 'utf8',


	),