C
C
Crash2018-06-19 16:21:29
Yii
Crash, 2018-06-19 16:21:29

How to set up a connection to the 2nd database for Query?

Yii2 has a wonderful class for fetching data from tables without using AR - yii\db\Query.
In a newly created project, I use 2 connections to different DBs at the same time. This is necessary in order to take data from the old database, reformat it in a new way, and write it to the new one.
Thus, for Query, I need to set the config for the old database, different from the default config.
Unfortunately, I did not find the appropriate setting. There is a getDb() method in AR, but for junk I don’t want to fence these models, all the same then in the trash.
How can I set up a connection to another database for this class?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2018-06-19
@Bandicoot

Tyk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question