2011-03-06 102 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。大寫第一個字母很重要,必須與您的班級名稱相匹配。