How does yii2 configure two mongo databases?
If configured like this, an error will be reported in the model.
But now the project needs to connect two databases, how should it be configured? ? ?
The default project uses:
mongodbFor example, his default first id should be:
But you are set to “mongo_dsp” and “mongo_dmp” so this problem will occur. To implement it, you can use it in the Model constructor:
Yii::$app->getDb("mongo_dsp");To achieve results!