2011-03-06 48 views
0

我使用phpMyAdmin创建了我的数据库和表格。我也建立了关系。原则2上的YAML映射例外

我当时就想拿到学说2创建YAML文件由我做这个命令:

PHP学说ORM:转换映射 --from数据库阳明/路径/到/夹具/模式

它创建* .dcm.yml文件并且看起来没问题。所以,我需要通过这样做是为了使实体:

PHP学说ORM:生成实体 /路径/到/型号

我得到不过这个错误:

[学说\ ORM \ Mapping \ MappingException] Class Callers \ dcm不是有效的 实体或映射超类。

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

异常跟踪:在 /用户/我/网站/项目/模块/ doctrine2 /班/学说/教义/ ORM()/制图/ MappingException.php:137个 学说\ ORM \制图\ MappingException :: classIsNotAValidEntityOrMappedSuperClass() 在 /用户/我/网站/项目/模块/ doctrine2 /班/学说/教义/ ORM /映射/司机/ YamlDriver。 Doctrine \ ORM \ Mapping \ Driver \ YamlDriver-> loadMetadataForClass() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:282 Doctrine \ ORM \ Mapping \ ClassMetadataFactory-> loadMetadata() at /Users/me/Doctrine \ ORM \ Mapping \ ClassMetadataFactory-> getMetadataFor() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php: Doctrine \ ORM \ Mapping \ ClassMetadataFactory-> getAllMetadata() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php: Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php:101 Doctrine \ ORM \ Tools \ Console \ Command \ Ge nerateEntitiesCommand-> execute() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Command/Command.php:150 Symfony \ Component \ Console \ Command \ Command-> run() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Application.php:187 Symfony \ Component \ Console \ Application-> doRun () 在 /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Application.php:113 的Symfony \元器件\控制台\应用 - >的run() 在 /Users/me/Sites/project/modules/doctrine2/bin/doctrine。PHP:40 包括()在 /用户/我/网站/项目/模块/ doctrine2 /斌/学说:4

我试图让学说2与MySQL的关系,因为Kohana中的一个模块工作。以为我会开始让教条工作,因为这确实是更难的部分。

这里是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 

那么,是什么问题呢?

回答

0

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