From 9babf2d1326a1de2838145bea5056f5299a1fed4 Mon Sep 17 00:00:00 2001 From: Thomas Beaujean Date: Wed, 15 Apr 2015 11:07:59 +0200 Subject: [PATCH] Add the get singleOrNull, get ScalarResult, etc.. --- .../Generator/TopRepositoryTemplate.html.twig | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Resources/views/Generator/TopRepositoryTemplate.html.twig b/Resources/views/Generator/TopRepositoryTemplate.html.twig index 799fe6e..0fc1055 100644 --- a/Resources/views/Generator/TopRepositoryTemplate.html.twig +++ b/Resources/views/Generator/TopRepositoryTemplate.html.twig @@ -54,5 +54,68 @@ class {{ tableName }}Repository extends EntityRepository return $results; } + /** + * Get the SingleResult of the query builder + * + * @return unknown The results + */ + public static function getQueryBuilderSingleResult(QueryBuilder $qb) + { + $query = $qb->getQuery(); + $results = $query->getSingleResult(); + + return $results; + } + + /** + * Get the OneOrNullResult of the query builder + * + * @return unknown The results + */ + public static function getQueryBuilderOneOrNullResult(QueryBuilder $qb) + { + $query = $qb->getQuery(); + $results = $query->getOneOrNullResult(); + + return $results; + } + + /** + * Get the getArrayResult of the query builder + * + * @return unknown The results + */ + public static function getQueryBuilderArrayResult(QueryBuilder $qb) + { + $query = $qb->getQuery(); + $results = $query->getArrayResult(); + + return $results; + } + + /** + * Get the ScalarResult of the query builder + * + * @return unknown The results + */ + public static function getQueryBuilderScalarResult(QueryBuilder $qb) + { + $query = $qb->getQuery(); + $results = $query->getScalarResult(); + return $results; + } + + /** + * Get the SingleScalarResult of the query builder + * + * @return unknown The results + */ + public static function getQueryBuilderSingleScalarResult(QueryBuilder $qb) + { + $query = $qb->getQuery(); + $results = $query->getSingleScalarResult(); + + return $results; + }