I have an entity NewsVersion
with ManyToMany :
class NewsVersion
{
...
/**
* @var NewsCategory[]|ArrayCollection
*
* @ORM\ManyToMany(
* targetEntity="AppBundle\Entity\NewsCategory",
* cascade={"persist"}
* )
* @ORM\JoinTable(name="news_version_categories")
*/
private $categories;
...
In my repository, when I call this :
$qb = $this->createQueryBuilder('nv')
->select('nv')
->innerJoin('nv.categories', 'nvc')
->addSelect('nvc');
return $qb->getQuery()->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
I have :
But When I call this :
$qb = $this->createQueryBuilder('nv')
->select('nv')
->innerJoin('nv.categories', 'nvc')
->addSelect('nvc.id');
I have :
Why nvc.id
don't return id
in categories
array ? I want return only id from my category, but in categories
array in NewsVersion
entity (same as first screen)