Php 实体映射注释中的Doctrine2@ORM
我是Doctrine2新手,使用以下命令从现有数据库创建了entitie类:Php 实体映射注释中的Doctrine2@ORM,php,orm,doctrine-orm,Php,Orm,Doctrine Orm,我是Doctrine2新手,使用以下命令从现有数据库创建了entitie类: .\vendor\bin\doctrine-module orm:convert-mapping --force --from-database annotation ./EXPORT/ 现在我有了我的课程,它们看起来是这样的: <?php namespace App\Model\Entity; // this line was not generated automatically use Doctrin
.\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;
....
看起来不错,但我不明白为什么docblock中的每个符号前面都使用了@ORM\。
当我创建查询时,除非我删除@ORM\bevore每个符号,否则它们不会工作。
我错过什么了吗?
我没有使用任何Zend/Symfony框架。。。。我只是在对composer使用条令/orm:~2.4
致意
MichaelORM引用顶部的名称空间快捷方式
use Doctrine\ORM\Mapping as ORM;
例如,您还可以将Id注释与完整名称空间一起使用,如下所示:
/**
* @Doctrine\ORM\Mapping\Id
*/
除此之外,我建议您查看注释文档,以正确运行条令
及
谢谢,但我仍然不明白为什么需要Doctrine\ORM\Mapping名称空间。我的查询:$qb->从'App\Model\Entity\Category','c'中选择'c.name,c.description'->;当我从注释中删除ORM名称空间并在该名称空间存在时停止工作时,返回它应该返回的所有内容。你能解释一下为什么会这样吗?在此之前,我将再次阅读您发送的文档,可能我遗漏了一些内容…我可能应该更仔细地阅读错误消息。我在这里找到了解决方案: