mongodb - yii2 how to configure two mongo databases
过去多啦不再A梦
过去多啦不再A梦 2017-05-02 09:24:09
0
1
807

How to configure two mongo databases in yii2?


If configured like this, an error will be reported in the model


But now the project needs to connect to two databases. How should it be configured? ? ?

过去多啦不再A梦
过去多啦不再A梦

reply all(1)
为情所困

The default project uses:Yii::$app->getDb($dbId);
对于mongodb来说,他默认的第一个id应该是:mongodb;
但是你是设置成了:"mongo_dsp"和"mongo_dmp"所以会出现这个问题,想要实现就可以在Model构造函数里面使用:
Yii::$app->getDb("mongo_dsp");to achieve the effect!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template