[英]Doctrine 2.2 ORM: After reverse-engineering from database MappingException is thrown
I'm using Zend Framework boilerplate without the virtual machine. 我正在使用没有虚拟机的Zend Framework样板。
My Application.ini, looks like this: 我的Application.ini如下所示:
;resources.doctrine.orm.entityManagers.default.metadataDrivers.annotationRegistry.annotationFiles[] = APPLICATION_PATH "/../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.adapterClass = "Doctrine\ORM\Mapping\Driver\XmlDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingNamespace = "Square\Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingDirs[] = APPLICATION_PATH "\..\library\Square\Entity"
;resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader"
;resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderCache = default
;resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderNamespaces.Square = "Square\Entity"
I have runed the command in CLI as in the example from here : 我已经在CLI中运行了命令,如以下示例所示:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/tools.html#reverse-engineering http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/tools.html#reverse-engineering
More specifically this one: 更具体地讲:
$ php doctrine orm:convert-mapping --from-database xml /path/to/mapping-path-converted-to-xml
And this generated my xml files with the following naming schema: {Entity}.dcm.xml 并使用以下命名模式生成了我的xml文件: {Entity} .dcm.xml
I have generated my Entity classes based on these XML files and then tried saving to the database with: 我已经基于这些XML文件生成了Entity类,然后尝试使用以下方法将其保存到数据库中:
try{
$this->_em->persist($this->_apikey);
$this->_em->flush();
}catch (Exception $e){
echo "Something went bad --> ".$e;
}
Where $this->_apikey = new Square\\Entity\\Apikeys();
其中$this->_apikey = new Square\\Entity\\Apikeys();
in the constructor method. 在构造方法中。
The Entity Manager throws up an exception: 实体管理器引发异常:
exception 'Doctrine\ORM\Mapping\MappingException' with message 'No mapping file found'
Why is Doctrine asking for a mapping file if the Entity class was generated upon them? 为什么Doctrine是否要求映射文件是否在其上生成了Entity类?
Am I doing something wrong? 难道我做错了什么?
Doctrine 2.2要求您保留xml文件,即使该文件是从它们反向工程的PHP类也是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.