phpMyAdmin を使用してデータベースとテーブルを作成しました。私もそこに関係を設定します。
次に、次のコマンドを実行して、Doctrine 2 に YAML ファイルを作成してもらいたいと思いました。
php doctrine orm:convert-mapping --from-database yml /path/to/fixtures/schema
*.dcm.yml ファイルが作成され、問題ないように見えます。したがって、次のようにしてエンティティを作成する必要がありました。
php doctrine orm:generate-entities /path/to/models
ただし、このエラーが発生します。
[Doctrine\ORM\Mapping\MappingException] クラス Callers\dcm は、有効なエンティティまたはマップされたスーパー クラスではありません。
-v フラグを追加すると、次のようになりました。
例外トレース: () at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/MappingException.php:137 Doctrine\ORM\Mapping\MappingException::classIsNotAValidEntityOrMappedSuperClass() at /Users/ me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/Driver/YamlDriver.php:55 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/Sites/project/modules/doctrine2/classes/doctrine/ Doctrine/ORM/Mapping/ClassMetadataFactory.php:176 Doctrine\ORM\Mapping\ClassMetadataFactory->getMetadataFor() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:123 Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata() at /Users/me/ Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php:101 Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand->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() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Application.php:113 Symfony\Component\Console\Application->run() at /Users/ me/Sites/project/modules/doctrine2/bin/doctrine.php:40 include() at /Users/me/Sites/project/modules/doctrine2/bin/doctrine: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
それで、何がうまくいかないのですか?