YII如何同时访问不同的数据库,比如mysql 和 memcachedb
如何封装memcachedb和mysql,写个基类?!
YII如何同时访问不同的数据库,比如mysql 和 memcachedb
如何封装memcachedb和mysql,写个基类?!
不行啊,如下配置:
‘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',
),