gpt4 book ai didi

php - 如何使用 doctrine symfony2 在表中添加列

转载 作者:行者123 更新时间:2023-12-02 04:38:24 28 4
gpt4 key购买 nike

我正在尝试使用 yml 格式将列添加到现有表中。添加了新列进入 .yml 文件并运行命令生成实体

php app/console doctrine:generate:entities PLibBundle:Contact

运行出现错误

"No identifier / primary key specified for Entity"

这是我的 yml 文件:

Application\PLibBundle\Entity\Contact:  type: entity  table: null  fields:    id:      type: integer      length: null      precision: 0      scale: 0      nullable: false      unique: false      id: true      generator:        strategy: IDENTITY    firstName:      type: string      length: 255      precision: 0      scale: 0      nullable: false      unique: false    lastName:      type: string      length: 255      precision: 0      scale: 0      nullable: false      unique: false    companyText:      type: string      length: 255      precision: 0      scale: 0      nullable: true      unique: false    email:      type: string      length: 255      precision: 0      scale: 0      nullable: true      unique: true    hasCustomHeadshot:      type: boolean      length: null      precision: 0      scale: 0      nullable: false      unique: false    createdOn:      type: datetime      length: null      precision: 0      scale: 0      nullable: false      unique: false    updatedOn:      type: datetime      length: null      precision: 0      scale: 0      nullable: false      unique: false  oneToOne:    address:      targetEntity: Application\PLibBundle\Entity\Address      cascade:        - remove        - persist      mappedBy: null      inversedBy: null      joinColumns:        addressId:          referencedColumnName: id      orphanRemoval: true  oneToMany:    phoneNumberAssociations:      targetEntity: Application\PLibBundle\Entity\ContactPhoneNumberAssociation      cascade:        - remove        - persist      mappedBy: contact      inversedBy: null      orphanRemoval: true      orderBy: null    subscriptionAssociations:      targetEntity: Application\PLibBundle\Entity\ContactSubscriptionAssociation      cascade:        - remove        - persist      mappedBy: contact      inversedBy: null      orphanRemoval: true      orderBy: null  manyToOne:    company:      targetEntity: Application\PLibBundle\Entity\Company      cascade: {  }      mappedBy: null      inversedBy: null      joinColumns:        companyId:          referencedColumnName: id      orphanRemoval: false  lifecycleCallbacks:    prePersist:      - beforePersist    preUpdate:      - beforeUpdate

最佳答案

异常信息就解开了这个谜团,你有这样的东西吗?

Contact:
type: entity
id:
id:
type: integer
generator:
strategy: AUTO
fields:
name:
type: string
length: 100

关于php - 如何使用 doctrine symfony2 在表中添加列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21429166/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com