Yii2:如何指定倍数数据库模式? [英] Yii2: how to specify multiples database schemas?

查看:80
本文介绍了Yii2:如何指定倍数数据库模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Yii2应用程序中使用的是PostgreSQL和默认数据库架构.

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

我创建了一个名为 laboratory 的新架构,我需要在common/config/main-local.php文件中对其进行定义.

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

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

<?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.

Yii2是否支持多重模式?

Is Yii2 supporting multiples schemas?

推荐答案

不需要更改它:

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

然后Gii代码生成器可以识别实验室模式(但是表名的自动完成功能无效).

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

这篇关于Yii2:如何指定倍数数据库模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆