我使用 phpMyAdmin 创建了我的数据库和表。我也在那里建立了关系。
然后我想通过执行以下命令让 Doctrine 2 为我创建 YAML 文件:
php 学说 orm:convert-mapping --from-database yml /path/to/fixtures/schema
它创建了 *.dcm.yml 文件,看起来还不错。所以我需要通过这样做来制作实体:
php 学说 orm:generate-entities /path/to/models
但是,我收到此错误:
[Doctrine\ORM\Mapping\MappingException] 类调用者\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() 在 /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/我/Sites/project/modules/doctrine2/bin/doctrine.php:40 include() 在 /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
那么出了什么问题呢?