Doctrine 2上的YAML Mapping异常

时间:2011-03-06 17:34:20

标签: mysql doctrine yaml relation

我使用phpMyAdmin创建了我的数据库和表。我在那里建立了关系。

然后我想通过执行以下命令让Doctrine 2为我创建YAML文件:

  

php doctrine orm:convert-mapping   --from-database yml / path / to / fixtures / schema

它创建了* .dcm.yml文件,看起来不错。所以我需要通过这样做来创建实体:

  

php doctrine orm:generate-entities   /路径/到/模型

但是我收到了这个错误:

  

[学说\ ORM \映射\ MappingException]   类Callers \ dcm无效   实体或映射的超类。

我添加了-v标志并得到了这个:

  

异常跟踪:()at   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/MappingException.php:137   学说\ ORM \制图\ MappingException :: classIsNotAValidEntityOrMappedSuperClass()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/Driver/YamlDriver.php:55   教义\ ORM \映射\驱动\ YamlDriver-> loadMetadataForClass()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:282   教义\ ORM \映射\ ClassMetadataFactory-> loadMetadata()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:176   教义\ ORM \映射\ ClassMetadataFactory-> getMetadataFor()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:123   教义\ ORM \映射\ ClassMetadataFactory-> getAllMetadata()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php:101   教义\ ORM \工具\控制台\命令\ GenerateEntitiesCommand->执行()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Command/Command.php:150   的Symfony \组件\控制台\命令\命令 - >运行()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Application.php:187   的Symfony \组件\控制台\应用 - > doRun()   在   /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Application.php:113   的Symfony \组件\控制台\应用 - >运行()   在   /Users/me/Sites/project/modules/doctrine2/bin/doctrine.php:40   include()at   /用户/ ME /站点/项目/模块/ doctrine2 / bin中/教义:4

我试图让Doctrine 2作为Kohana的模块与MySQL关系一起工作。我以为我会开始让Doctrine工作,因为那真的是更难的部分。

这是它创建的YAML文件:

Callers:
  type: entity
  table: callers
  fields:
    id:
      id: true
      type: integer
      unsigned: false
      nullable: false
      generator:
        strategy: AUTO
    firstname:
      type: string
      length: 75
      fixed: false
      nullable: true
    lastname:
      type: string
      length: 75
      fixed: false
      nullable: true
    company:
      type: string
      length: 75
      fixed: false
      nullable: true
    email:
      type: string
      length: 150
      fixed: false
      nullable: true
    datecreated:
      type: datetime
      nullable: false
    dateupdated:
      type: datetime
      nullable: false
    address1:
      type: string
      length: 150
      fixed: false
      nullable: true
    address2:
      type: string
      length: 150
      fixed: false
      nullable: true
    city:
      type: string
      length: 100
      fixed: false
      nullable: true
    state:
      type: string
      length: 50
      fixed: false
      nullable: true
    zip:
      type: string
      length: 10
      fixed: false
      nullable: true

那出了什么问题?

1 个答案:

答案 0 :(得分:0)

我刚刚遇到类似的错误。确保您的.dcm.yml文件名为Callers.dcl.yml而不是callers.dcl.yml。大写的第一个字母很重要,必须与您的班级名称相匹配。