Skip to content

Instantly share code, notes, and snippets.

@caiaffa
Created August 13, 2020 17:01
Show Gist options
  • Save caiaffa/249ab2258b7bf15d544ecc0dc3d8a663 to your computer and use it in GitHub Desktop.
Save caiaffa/249ab2258b7bf15d544ecc0dc3d8a663 to your computer and use it in GitHub Desktop.
public function findDataByProductId(int $productId)
{
$qb = $this->createQueryBuilder('p');
$qb
->select('p, pmmp')
->leftJoin('p.contractsRenovation', 'pmmp')
->where('p.id = :productId')
->setParameter('productId', $productId);
return \array_map(
function (array $result) {
return new ProductDto($result['name'], $result['contractsRenovation']);
},
$qb->getQuery()->getResult(Query::HYDRATE_ARRAY)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment