아래 doctrine docs 예제를 사용하여 제품을 쿼리 할 때 모든 기능을 반환하고 싶습니다.관계가 존재하는 경우 OneToMany 'Child'가 'Parent'개체를 반환합니다.
그래서 효과적으로
selecting all products where feature.product_id = product.id
그러나 가능하면이 교리의 객체 지향 방법을하고 싶습니다. 이 관계를 반대 방향으로 일치시키는 교리에 어떤 방법이 있습니까?
<?php
use Doctrine\Common\Collections\ArrayCollection;
/** @Entity **/
class Product
{
// ...
/**
* @OneToMany(targetEntity="Feature", mappedBy="product")
**/
private $features;
// ...
public function __construct() {
$this->features = new ArrayCollection();
}
}
/** @Entity **/
class Feature
{
// ...
/**
* @ManyToOne(targetEntity="Product", inversedBy="features")
* @JoinColumn(name="product_id", referencedColumnName="id")
**/
private $product;
// ...
}
감사합니다, product.id = feature.product_id는 제품 테이블의 ID를 가정 한 결과를 반환한다이 경우에 제품을 선택
내가 틀렸다면 정정하십시오. 그러나 이것은 대략 당신이해야 할 일입니다. ** 기능이 지정된 ** 제품을 검색하지만, ** 기능이없는 제품은 건너 뜁니다. 내가 맞습니까? –
정확히 @JovanPerovic 지연된 응답으로 미안합니다 –