How to make two and more database connections in Yii mongodbsuite?
I write 2 DB in main.php
‘components’ => array(
'mongodb' => array(
'class' => 'common\extentions\MongoDB',
'connectionString' => 'mongodb://localhost:27017/table1',
'dbName' => 'table1',
'fsyncFlag' => false,
'persistentConnection' => 'x',
'replicaSet' => false,
'safeFlag' => true,
'useCursor' => false,
),
'mongodb2' => array(
'class' => 'common\extentions\MongoDB',
'connectionString' => 'mongodb://localhost:27017/table2',
'dbName' => 'table2',
'fsyncFlag' => false,
'persistentConnection' => 'x',
'replicaSet' => false,
'safeFlag' => true,
'useCursor' => false,
),
) But how use mongodb2 in query (ex: ->findByAttributes()) i don’t know. Please type some example query to mongodb2.
In my project all models extends \web\extensions\MongoDocument (NOT CActiveRecord). So article Multiple db support in Yii not work for me.