使实体具有多个数据库 [英] make entities with multiple databases

查看:64
本文介绍了使实体具有多个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在Web应用程序上进行大型重构/增强。我们决定使用Symfony4。

I have to do large refactoring/enhancements on web apps. We decided to use Symfony4.

我想定义2个(或更多)数据库:旧数据库和新数据库。

(在未来,我认为将有更多的位置个人在多个Web应用程序中常见的数据库)

I want to define 2 (or more) databases: the old one and the new one.
(In the future, I think to have more location, person databases common at several web apps)

在我的研究中,我使用多个实体管理器,创建提到的数据库,然后创建我的 src / Entity / Main src / Entity / Customer 文件夹。

In my researches, I use Multiple Entity Managers, create my databases as mentionned, then create my src/Entity/Main and src/Entity/Customer folders.

然后,我要创建我的实体,尤其是带有 php bin / console make:entity的新实体 code>,但会在 Entity 文件夹中创建文件,而不是在 Entity / Main (默认)或 Customer 并返回

Then, I want to create my entities, especially new one with php bin/console make:entity but it creates files in Entity folder, not in Entity/Main (default) or Customer and returns


[错误] make:entity仅支持注释映射

[ERROR] Only annotation mapping is supported by make:entity

是否有使用此 make:entity的解决方案命令还是我应该自己定义所有实体文件?

Are there any solution to use this make:entity command or should I define all entity files myself?

注意:我不放置 config / packages / doctrine.yaml ,它与帮助示例中的相同,除了 server_version:'5.6'符合我的MariaDB版本

Nota: I don't put my config/packages/doctrine.yaml, it is the same as in help sample except server_version: '5.6' to be compliant with my MariaDB version

推荐答案

Main 中创建 Product 实体的答案是:

The answer to create Product entity in Main is:

php bin/console make:entity Main\\Product

并在 Customer 中创建 Customer 实体是:

php bin/console make:entity Customer\\Customer

这篇关于使实体具有多个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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