Last active
January 30, 2020 10:21
-
-
Save gdarquie/27f41af426c6f8396f402d0cc7a47c6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function findAllDistinctFragments(int $limit) | |
{ | |
$sql = "SELECT DISTINCT ON (f.code) * FROM fragment f ORDER BY f.code, f.created_at DESC "; | |
$rsm = new ResultSetMappingBuilder($this->getEntityManager()); | |
$rsm->addRootEntityFromClassMetadata(Fragment::class, 'f'); | |
$query = $this->getEntityManager()->createNativeQuery($sql, $rsm); | |
return $query->getResult(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment