나는 specialtyarea와 의사로 알려진 두 개의 테이블이있는 간단한 심포니 컨트롤러를 작성했습니다.
이것은 테이블의 기본 구조입니다.
specialtyarea
-----------------
id | name |
-----------------
1 | dentist |
2 | physician |
의사 테이블은 다음과 specialtyarea
같이 관련됩니다 .
Physician
--------------------
id | name | specfk |
--------------------
1 | John | 1 |
2 | Doe | 2 |
3 | Ann | 2 |
전문 분야가 2 인 모든 의사를 불러 오려고합니다
이것은 내 코드 스 니펫입니다.
public function getAllPhysicianAction($specId)
{
$id = $this->getDoctrine()->getRepository('Bundle:SpecArea')
->find($specId); //assuming that this returns all the id from the specialty table
$allPhysician = $id->getPhysician()->... //kind of lost here
}
전문 ID를 사용하여 의사 테이블에서 모든 레코드를 검색하려면 어떻게해야합니까?
의사 저장소에서 findBy를 호출 할 수 있다고 믿습니다.
/**
* @Route("/physicians/{specId}", name="getAllPhysician")
*/
public function getAllPhysicianAction($specId)
{
$allPhysician = $this->getDoctrine()
//call the repository of your physician table
->getRepository('Bundle:physician')
->findBy(['specfk' => $specId]);
var_dump($allPhysician);
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다