我是Doctrine2新手,使用以下命令从我现有的数据库创建了完整的类:
.\vendor\bin\doctrine-module orm:convert-mapping --force --from-database annotation ./EXPORT/现在我上了课,他们看起来是这样的:
<?php
namespace App\Model\Entity; // this line was not generated automatically
use Doctrine\ORM\Mapping as ORM;
/**
*
* Category
*
* @ORM\Table(name="category")
* @ORM\Entity
*/
class Category
{
/**
* @ORM\var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
....看起来不错,但我不明白为什么在docblocks中的每个符号之前都使用“@ORM”。当我创建查询时,除非删除"@ORM\“,否则它们无法工作。我错过了什么吗?我没有使用任何框架(Zend/Symfony.)。我只是使用“理论/orm”:"~2.4“与作曲家。
向迈克尔问好
发布于 2015-03-15 17:09:51
ORM引用顶部的命名空间快捷方式。
use Doctrine\ORM\Mapping as ORM;例如,您还可以在完整的命名空间中使用Id注释,如下所示:
/**
* @Doctrine\ORM\Mapping\Id
*/此外,我建议查看注释文档,以使理论正确运行。
(http://doctrine-common.readthedocs.org/en/latest/reference/annotations.html和http://doctrine-orm.readthedocs.org/en/latest/reference/annotations-reference.html)
https://stackoverflow.com/questions/29062725
复制相似问题