我正在尝试定义一个OneToMany
双向(以避免ManyToMany
和额外的表),我正在按照这里的文档所说的做(我想),但我肯定遗漏了一些东西,因为我在运行doctrine:schema:validate
命令后收到了这个错误:
关联PlatformBundle\Entity\Downloads#标识符指的是不存在的拥有方字段PlatformBundle \Entity\identifier#Downloads。
这就是实体的样子(只是相关字段):
class Identifier
{
/*
* @var Downloads
* @ORMManyToOne(targetEntity="Downloads", inversedBy="identifier")
* @ORMJoinColumn(name="downloads_id", referencedColumnName="id")
*/
protected $downloads;
}
class Downloads
{
/**
* @var Collection
* @ORMOneToMany(targetEntity="Identifier", mappedBy="downloads")
*/
protected $identifier;
public function __construct() {
$this->identifier = new ArrayCollection();
}
}
这是一个将下载分配给多个标识符的关联。我做错了什么或错过了什么?
您在Identifier
类中错误地输入了*
/**<- this one could cost you many hours :P
* @var Downloads
* @ORMManyToOne(targetEntity="Downloads", inversedBy="identifier")
* @ORMJoinColumn(name="downloads_id", referencedColumnName="id")
*/
protected $downloads;