-1
범주와 섹션간에 OneToMany 관계가 있습니다. 내가 뭘 하려는지 섹션에 대한 편집을 구현하는 것입니다. 그래서 내 편집 작업은 지금까지 다음과 같습니다레코드 배열을 통해 검색
/**
*
*
* @Route("category/{category_id}/section/{id}/edit", name="section_edit")
* @Method("GET")
* @Template()
*/
public function editAction($category_id, $id)
{
$em = $this->getDoctrine()->getManager();
$category = $em->getRepository('MyOwnBundle:Category')->find($category_id);
if (!$category) {
throw $this->createNotFoundException('Unable to find Category entity.');
}
////.....
}
모든 매우 간단하지만, 난 정말 $ 범주에 속하는 부분을 검색하는 방법을 모르겠어요. 편집을 수행하려면 id == $ id 인이 특정 레코드가 필요합니다. 분명히 모든 섹션을 통해 단순히 볼 수 없다. 왜냐하면 내가 정말로 $ 카테고리에 속하는지 알 수 없기 때문이다. 내가 이것을 할 수있게 해주는 간단한 방법이나,이 간단한 루프를 통해 $category->getSections()
을 하나씩 처리해야합니까?