简体   繁体   English

使用Symfony和Doctrine创建多个表

[英]Creating multiple tables with Symfony & Doctrine

Starting my first Symfony/doctrine project I created 2 entities (user & property) using: 开始我的第一个Symfony / doctrine项目时,我使用以下方法创建了2个实体(用户和属性):

$php app/console doctrine:generate:entity

This works fine and gives me the two needed php files with the classes and annotions. 这工作正常,并为我提供了两个需要的PHP文件以及类和注释。

After this I want to create the corresponding tables in my database using: 之后,我想使用以下方法在数据库中创建相应的表:

$php app/console doctrine:schema:update --force

Only the first table (user) is created. 仅创建第一个表(用户)。 What's going wrong? 怎么了 What do i have to do to have both tables created. 我必须怎么做才能创建两个表。 BTW: no error message received... 顺便说一句:没有收到错误消息...

Try to do 试着做

php app/console doctrine:generate:entities

before 之前

php app/console doctrine:schema:update --force

SOLVED! 解决了! There was a syntax error in the property class. 属性类中存在语法错误。 But doctrine:schema:update did not give any error... :-( 但是doctrine:schema:update没有给出任何错误... :-(

When trying doctrine:schema:create I got the error message. 尝试使用doctrine:schema:create时,出现错误消息。 Corrected it and afterwards doctrine:schema:update worked well! 更正了它,之后doctrine:schema:update效果很好!

always backing up your entities before you update schema .. 在更新架构之前,请始终备份您的实体。

for backing up entities write 用于备份实体写

>php app/console doctrine:generate:entities projectname

If there is Error In entity It will show you. 如果实体中有错误,它将显示给您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM