3
我在Symfony2中有以下实体,一个产品实体和一个评论实体。Symfony2 ORM实体,ManyToOne双向
产品实体:
/**
* @ORM\Entity
* @ORM\Table(name="product")
*/
class Product
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100)
*/
protected $name;
的意见实体:
/**
* @ORM\Entity
* @ORM\Table(name="productComment")
*/
class ProductComment
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Acme\ProductsBundle\Entity\Product", inversedBy="comments")
* @ORM\JoinColumn(name="product_id", referencedColumnName="id")
*/
protected $product;
}
我的问题是,我不知道如何从一个产品对象的意见。
感谢Hasts它的工作原理 – 2013-03-03 00:34:43