2015-04-02 181 views
1

我试图从字段'动作'中从我的数据库中拉出一个值,它是一个JSON字符串,但是现在我将它存储为单个值,这就是:Symfony JSON输出包括字段名称

'command'=>'get','target'=>'location' 

然而,当我把它从它包含的字段名称,这是我不希望的DB,见下图:

[{"action":"'command'=>'get','target'=>'location'"}] 

我的代码是在这里:

$em = $this->getDoctrine()->getManager(); 
    $query = $em->createQueryBuilder(); 
    $q = $query->select('z.action') 
    ->from('AppBundle:ZeusUsers', 'z') 
    ->where('z.id = ?1') 
    ->setParameter(1, $id) 
    ->getQuery(); 


    $action = $q->getResult(); 
    return new Response(json_encode($action)); 

所以我只需要知道如何获取不包含字段名称的字段值?

回答