我正在使用Doctrine 2,我想生成我的数据库的ORM,但我不想选择db的所有表。
例如,在这个db:
中我想用这个命令选择表2:
doctrine:mapping:convert --from-database yml ./src/Application/TestBundle/Resources/config/doctrine/metadata/orm --filter="Table2"
我有一个错误:
表Table_1没有主键。 Doctrine不支持没有主键的表的逆向工程。
好的,我知道,但我不想在我的ORM中使用我的表1。当我的表1有主键时,我可以过滤表。我见过 Generating a single Entity from existing database using symfony2 and doctrine,但它不起作用。
答案 0 :(得分:2)
忽略表是解决方案:
doctrine:
dbal:
schema_filter: ~^(?!Table1)~
答案 1 :(得分:0)
在最近版本的 Doctrine bundle 中,必须在连接级别配置模式过滤器,因此:
doctrine:
dbal:
default_connection: default
connections:
default: # <- your connection name
url: '%env(DATABASE_URL)%'
schema_filter: '#^(?!table_to_exclude)#'
答案 2 :(得分:-1)
Doctrine首先验证您的表,然后才执行该命令。 因此,您应该始终拥有有效的数据库架构,以便对其进行任何操作。