避免多对多关系中的重复 - Doctrine DQL

noob alert;

I have Post and Tag Entities like this:

Post.php

 /**
 * Many posts can have many tags. This is the owning side.
 * @ORM\ManytoMany(targetEntity="Tag", inversedBy="posts")
 * @ORM\JoinTable(name="post_tag")
 */
 protected $tags;

Tag.php

 /**
 * Many tags can belong to many different posts. This is the inverse side
 * @ORM\ManytoMany(targetEntity="Post", mappedBy="tags")
 */
 protected $posts;

Now, I want to query all posts with their tags.

For that, I'm using queryBuilder in my Repository and successfully able to retrieve results.

$query = $this->createQueryBuilder('P')
        ->select('P.title, T.name')
        ->leftJoin('P.tags', 'T')
        ->where('P.id = 1')
        ->getQuery()
        ->execute();

But as you can possibly imagine, this query fetches duplicates. So, if I had two tags for a post, there would be two similar posts inside the array.

Output

array(
  array(title=>'Post One', name=>'php'),
  array(title=>'Post One', name=>'python'),
)

Is there a doctrine way to turn these tags into an array collection and stuff this back into the final post array.