2017-04-13 4 views
0

정말 이상한 일이 일어나고 있습니다. 다음 코드는 슬림 3과 Doctrine 2를 사용하여 웹 서비스에 요청한 것입니다. 빈 응답을 표시합니다. 사실을 알고 있습니다. 배열이 채워지지만 그것은 빈 반환됩니다!빈 응답 웹 서비스 Doctrine 2 Slim 3

+0

var_dump ($ data_response)는 무엇을 출력합니까? –

답변

0

json_encode($data_response)false을 반환)

$data = $request->getParsedBody(); 

    $intervention_items = $this->em->getRepository('App\Entity\V_Interventionitems') 
      ->findAll(array('ic_interventiontype_id' => $data['it_id'])); 

    foreach ($intervention_items as $int_items){ 
     $data_response[] = $int_items->toArray(); 
     //echo json_encode($int_items->toArray()); here prints the info right 
    } 

    return $response->withStatus(200) 
     ->withHeader('Content-Type', 'application/json') 
     ->write(json_encode($data_response)); //here returns empty 

나는이 문제가 매우 아마추어하지만 난 나를 도와 내 친구의 Knoledge를 호출하고 알고있다. 무엇이 잘못되었는지 알아 보려면 json_last_error()을 사용하십시오.