1. When multiple database connection components are added in Yii 2.0
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=62.234.135.47;dbname=pcs_api',
'username' => 'sq_pcs',
'password' => '',
'tablePrefix' => 'pa_',
'charset' => 'utf8mb4',
'enableSchemaCache' => false,
'schemaCacheDuration' => 3600,
'schemaCache' => 'redisCache',
],
'statDb' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=62.234.135.47;dbname=pcs_stat',
'username' => 'sq_pcs',
'password' => '',
'tablePrefix' => 'ps_',
'charset' => 'utf8mb4',
],
],
2. When the database connection ID is set to statDb, the table name dropdown list only shows the tables under statDb, as shown in Figure 1

3. When generating a model file under statDb, getDb() is additionally generated, as shown in Figure 2

/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('statDb');
}
4. When the database connection ID is set to db, the tables under db do not appear in the table name dropdown list, so you need to fill in the corresponding information manually, as shown in Figure 3

5. When generating a model file under db, getDb() is not generated because db is the default, as shown in Figure 4

6. After clicking Preview or Generate, when the database connection ID is set to db, the table name dropdown list only shows the tables under db, as shown in Figure 5

