2017-04-13 7 views
0

本当に奇妙なことが起こっています。次のコードは、Slim 3とDoctrine 2を使用してWebサービスでリクエストしたものです。空のレスポンスを指定しています。配列がいっぱいになっていますが、空に戻ります!空のレスポンスWebサービスDoctrine 2 Slim 3

$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を呼び出しています;)

+0

var_dump($ data_response)は何を出力しますか? –

答えて

0

json_encode($data_response)falseを返しています。何が間違っているか調べるにはjson_last_error()を使ってください。

関連する問題