我的配方实体:
/**
* @ORM\ManyToMany(targetEntity="Category", inversedBy="recipes")
*/
private $categories;我的类别实体:
/**
* @ORM\ManyToMany(targetEntity="Recipe", inversedBy="categories")
* @ORM\JoinTable(name="recipe_category")
*/
private $recipes;好的,这是来自http://www.youtube.com/watch?v=kPrgoe3Jrjw&feature=related的。
有了这两个拥有的方面,一切都很好。但cli给出了错误:‘名为recipe_category的表已经存在。有人知道最佳实践是如何实现的吗?
发布于 2013-10-30 00:03:42
您必须更新其他实体,如:
class Recipe
{
public function addCategory($cat)
{
$car->addRecipe($this);
$this->categories->add($cat);
return $this;
}
public function removeCategory($cat)
{
$cat->removeRecipe($this);
$this->categories->removeElement($cat);
return $this;
}
}https://stackoverflow.com/questions/11385808
复制相似问题