Skip to content

Instantly share code, notes, and snippets.

@bakura10
Last active December 14, 2015 08:48
Show Gist options
  • Save bakura10/5060100 to your computer and use it in GitHub Desktop.
Save bakura10/5060100 to your computer and use it in GitHub Desktop.
<?php
// In the PostRepository
public function getBySlugCategory($slugCategory)
{
$dql = 'SELECT p FROM Application\Entity\Post p ' .
'JOIN Application\Entity\PostCategory pc WITH pc.category MEMBER OF p.categories ' .
'JOIN pc.category c '
'WHERE c.slug = :slug';
return $entityManager->createQuery($dql)
->setParameter('slug', $slugCategory)
->getResult();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment