symfony doctrine entity onetomany由于不工作而被映射

时间:2016-06-23 02:44:05

标签: php mysql symfony doctrine-orm

我使用symfony并且真的需要一些帮助。 我有一个TableList实体列出所有具有id,name,description等的表。 我还有一个TableDesc实体列出与表相关的所有字段。每行都有table_id作为TableList的外键,用于标识哪个表。

TableList.php

/**
 * @ORM\OneToMany(targetEntity="TableBundle\Entity\TableDesc", mappedBy="table")
 */
protected $fields;

/**
 * Constructor
 */
public function __construct()
{
    $this->fields = new \Doctrine\Common\Collections\ArrayCollection();
}

/**
 * Get fields
 *
 * @return \Doctrine\Common\Collections\Collection
 */
public function getFields()
{
    return $this->fields;
}

TableDesc.php

/**
 * @var \TableBundle\Entity\TableList
 *
 * @ORM\ManyToOne(targetEntity="TableBundle\Entity\TableList", inversedBy="fields")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="table_id", referencedColumnName="id")
 * })
 */
private $table;

我想知道为什么我总是将TableList中的$字段等于null?我在TableList中有记录。 有人可以指出出了什么问题吗?如有必要,我很乐意提供更多代码。 非常感谢你!

0 个答案:

没有答案