Symfony从数据库生成特定实体 [英] Symfony Generating Specific Entities from the Database

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

问题描述

我有一个更大的数据库,我想创建4个表的实体。我已经参考了这个 Symfony Cookbook ,但没有帮助我得到我



步骤1 - 从数据库导入



  php app / console doctrine:mapping:import --force AcmeBlogBu​​ndle xml 

可以导入特定的表吗?或者以Abc%开头的所有表?)这个命令会执行什么?



步骤2 - 将导入转换为Annotaction | Yml | XML



  php app / console doctrine:mapping:convert annotation ./src 

问题在这里:即使我删除导入的文件并留下我感兴趣的特定的orm.xml,它们似乎仍然影响到这个命令。有没有缓存清除或什么??



步骤3 - 创建实体



  php app / console doctrine:generate:entities AcmeBlogBu​​ndle 

我没有这里存在任何问题。但是,要达到这一点,需要创建和删除许多不必要的文件,这是从版本控制的角度来看是一个真正的头痛。

解决方案

我认为步骤应该在下面安排,你需要使用 - filter 为特定表格



Step1

  php app / console doctrine:mapping:convert annotation / src / App / MyBundle / Resources / config / doctrine --from-database --filter =table_name

Step2 现在您可以应用导入

  php app / console doctrine:mapping:import AppMyBundle annotation --filter =table_name

Step3

  php app / console doctrine:generate:entities AppMyBundle --no -backup 


I have a larger database and I'd like to create entities for 4 tables. I'v been referencing this Symfony Cookbook but it's not help quite getting me where I want to be.

Step 1 - Import From Database

php app/console doctrine:mapping:import --force AcmeBlogBundle xml

Question Here: Can you import specific tables? or all tables that start with 'Abc%'?) What command would do this?

Step 2 - Convert the import to Annotaction|Yml|XML

php app/console doctrine:mapping:convert annotation ./src

Problem here: Even if I delete the imported files and leave the specific orm.xml I'm interested in, they still seem to affect this command. Is there a cache to clear or something??

Step 3 -- Create the Entities

php app/console doctrine:generate:entities AcmeBlogBundle

I haven't had any problems here.. However, getting to this point requires creating and deleting a lot of unnecessary files which is a real headache from a version control perspective.

解决方案

I think the steps should be done in below arrange and you need to use --filter for the specific table:

Step1

php app/console doctrine:mapping:convert annotation  /src/App/MyBundle/Resources/config/doctrine --from-database --filter="table_name"

Step2 Now you can apply importing

php app/console doctrine:mapping:import AppMyBundle annotation --filter="table_name"

Step3

php app/console doctrine:generate:entities AppMyBundle --no-backup  

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

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