0

我的实体代码:

GameShelf\GamesBundle\Entity\Game:
    type: entity
    table: games
    id:
        id:
            type: integer
            generator: { strategy: AUTO }
    fields:
        parent_id:
            type: integer
            length: 11
        name:
            type: string
            length: 200
        slug:
            type: string
            length: 200
        reldate:
            type: date
        genres:
            type: text
        platforms:
            type: text
        developers:
            type: text
        desc:
            type: text
        desc_src:
            type: text
        rate:
            string: integer
            lenght: 10

我跑php app/console doctrine:generate:entities GameShelf\GamesBundle\Entity\Game了,它回来了Namespace "GameShelf\GamesBundle\Entity\Game" does not contain any mapped entities.。怎么了?我按照这里的文档

4

1 回答 1

7

请查看 Game.orm.yml 文件的以下代码。

GameShelf\GamesBundle\Entity\Game:
  type: entity
  table: null
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: AUTO
    parent_id:
      type: integer
      length: 11
    name:
      type: string
      length: 200
    slug:
      type: string
      length: 200
    reldate:
      type: datetime
    genres:
      type: text
    platforms:
      type: text
    developers:
      type: text
    desc:
      type: text
    desc_src:
      type: text
    rate:
      type: integer
      length: 10

以下内容已更正,可能有助于解决您的问题。

  • 您的身份声明很不稳定。
  • “比率”列的“长度”中的错字
  • 没有这样的类型“日期”,只有“日期时间”
  • 看起来您使用 4 个空格制表符,YAML 需要 2 个空格制表符

在我自己的配置上测试了正确的 YAML,并能够使用以下命令创建实体:

app/console generate:doctrine:entities --no-backup <Your Bundle>
app/console doctrine:schema:update --dump-sql
app/console doctrine:schema:update --force
于 2013-01-02T13:10:22.457 回答