저는 PHP에 매우 익숙하며 필수적으로 GET 요청을 받고 테이블에 저장된 모든 사용자를 반환하는 API를 만드는 데 어려움이 있습니다. 이 애플리케이션은 Zend Framework 2와 Doctrine을 사용합니다.Doctrine findby가 모든 사용자를 표시하기 위해 모든 행을 반복합니다.
컨트롤러 :
public function viewAllAction(){
$restService = $this->getServiceLocator()->get("Rest");
$restService->auth();
$business = $restService->getIdentity();
$bizID = $business->getId();
$clientModel = $this->getServiceLocator()->get('clientModel');
$clients = $clientModel->findAllByBusinessID($bizID);
$params['client'] = array(
"name" => $clients->getName(),
"email" => $clients->getEmail(),
"phone" => $clients->getPhone(),
"address" => $clients->getAddress(),
"suburb" => $clients->getSuburb(),
"postcode" => $clients->getPostcode(),
"state" => $clients->getState(),
"country" => $clients->getCountry(),
);
return $restService->send($params);
}
모델 : 나는 성공적으로 데이터를 검색하고 나머지를 통해 그것을 반환 할 수 있습니다 순간
public function findAllByBusinessID($business_id){
$clientRepository = $this->getMapper()->getRepository(self::ENTITY_CLASS);
$clients= $clientRepository->findBy(array("bid" => $business_id));
foreach($clients as $client) {
return $client;
}
}
하지만, 첫 번째 세트 (행)의 데이터 . 동일한 비즈니스 ID를 가진 테이블에 더 많은 것이 있습니다.
처음 비즈니스 ID 대신 동일한 비즈니스 ID가있는 모든 행을 반환하는 방법은 무엇입니까? 고맙습니다!