Reputation: 9269
I have a query in a repository like :
$qb->select('f.state as link')
->from('MyProjectBundle:Friend', 'f')
->where('CONDITIONS');
return $qb->getQuery()->getResult();
So, this query return the state with you and a friend. In my controller i return :
return array('link' => $state);
$state is the result of my query. I can only have one result with this query, it's just the state with ONE other user. So, when i check the response, i have (in json) :
{
"link": [
{
"link": 1
}
]
}
How can i remove the array [] in this json ? It's useless here.. Thanks !
Upvotes: 0
Views: 99
Reputation: 391
You can use getSingleScalarResult()
method as explained here :
$qb->select('f.state as link')
->from('MyProjectBundle:Friend', 'f')
->where('CONDITIONS');
return $qb->getQuery()->getSingleScalarResult();
Upvotes: 1