Symfony Doctrine query - get a list of children for each parent
<p>What I'm currently trying to do is create a query that returns a result with parent names and a <strong>list</strong> of child names. </p>

<p>For example, say we have two tables <code>Category</code> and <code>Product</code>, where <code>Category</code> has many <code>Product</code> entities. I understand that I can directly access the children using <code>getProducts()</code>, or if I didn't have an association setup using shared IDs and joins. However, it's at this point I'm unsure how to proceed, in essence, I want a result that looks like this:</p>

<pre><code>| Category.name | Product.name |
| Cars          | BMW, Volvo, Fiat
| Bikes         | BMX, Mountain Bike, Road Bike
</code></pre>

<p>I think the SQL term I'm looking for is <a href="http://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-group_concat.php" rel="nofollow noreferrer">GROUP_CONCAT</a>, but that doesn't appear to be in <a href="https://stackoverflow.com/questions/10850345/symfony2-how-to-use-group-concat-in-querybuilder">doctrine2</a>. So before I go marching off attempting to install an extension I don't really understand, I'd like to know if there is a simpler solution using Doctrine and the default query builder?</p>

<p><strong>Update:</strong></p>

<p>Using @Wilt's answer, I extended it slightly to produce the exact table above:</p>

<pre><code>$qm = $this-&gt;getEntityManager()-&gt;createQueryBuilder();
$qm-&gt;select('c', 'p')
   -&gt;from('AppBundle:OmicsExperimentTypeStrings', 'c')
   -&gt;leftJoin('c.omicsExperimentSubTypeStrings', 'p');
// Get query result as array for easier manipulation.
$results = $qm-&gt;getQuery()-&gt;getArrayResult();

$res = [];

// Iterate array structure and get c.name and an array of p.name.
foreach($results as $category) {
    $res[$category['name']] = [];
    foreach([$category['products']] as $productsArray) {
        foreach ($productsArray as $product) {
            array_push($res[$category['name']],$product['name']);
        }
    }
}

return $res;
</code></pre>