实体映射注释中的 Doctrine2 @ORM
Doctrine2 @ORM in entity mapping annotation
我是 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;
....
看起来不错,但我不明白为什么在文档块中的每个符号之前都使用“@ORM\”。
当我创建查询时,它们不会工作,直到我在每个符号之前删除这个“@ORM\”。
我错过了什么?
我没有使用任何框架 (Zend/Symfony...)。我只是使用 "doctrine/orm": "~2.4" with composer.
此致
迈克尔
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)
我是 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;
....
看起来不错,但我不明白为什么在文档块中的每个符号之前都使用“@ORM\”。 当我创建查询时,它们不会工作,直到我在每个符号之前删除这个“@ORM\”。 我错过了什么? 我没有使用任何框架 (Zend/Symfony...)。我只是使用 "doctrine/orm": "~2.4" with composer.
此致 迈克尔
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)