duandiaoqian5795
2017-11-10 18:09
浏览 307
已采纳

Yii2:如何指定多个数据库模式?

I am using PostgreSQL and the default database schema in my Yii2 application.

I created a new schema called laboratory and I need to define it in the common/config/main-local.php file.

This is my current main-local.php file:

<?php
return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'pgsql:host=localhost;dbname=travel',
            'username' => 'aaaa',
            'password' => 'bbbb',
            'charset' => 'utf8',
        ],
    ],
];

How can I add the laboratory schema in this file? I need both schemas.

Is Yii2 supporting multiples schemas?

图片转代码服务由CSDN问答提供 功能建议

我在Yii2应用程序中使用PostgreSQL和默认数据库模式。

我创建了一个名为 laboratory 的新模式,我需要在common / config / main-local.php文件中定义它。

这是我当前的< strong> main-local.php 文件:

 &lt;?php 
return [
'components'=&gt;  [
'db'=&gt;  [
'class'=&gt;  'yii \ db \ Connection',
'dsn'=&gt;  'pgsql:host = localhost; dbname = travel',
'username'=&gt;  'aaaa',
'密码'=&gt;  'bbbb',
'charset'=&gt;  'utf8',
],
],
]; 
   
 
 

如何在此文件中添加实验室模式? 我需要两个模式。

Yii2是否支持多个模式?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • duanjian4698 2017-11-13 12:00
    最佳回答

    It wasn't necessary to change it:

    <?php
    return [
        'components' => [
            'db' => [
                'class' => 'yii\db\Connection',
                'dsn' => 'pgsql:host=localhost;dbname=travel',
                'username' => 'aaaa',
                'password' => 'bbbb',
                'charset' => 'utf8',
            ],
        ],
    ];
    

    Then Gii code generator recognizes the laboratory schema (but autocomplete for Table Name doesn't work).

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题