How to set db connection in yii-db-query?
I have a 3 database connection:
db, db2 and db3
When I used this default Query:
$query = (new \yii\db\Query())
->select('*')
->from('trans_journal')
->all();
It will return an error. The trans_journal is not found, because the trans_journal is from the db2 connection.
And when I used this Query:
$query = (new \yii\db\Query())
->select('*')
->from('trans_journal')
->all(\Yii::$app->db2);
The query will be successfully generated but the problem is it will return an array.
Is there another way to solved this?