From b353dc51721c4a3a1abf0664f6f022930b8b3577 Mon Sep 17 00:00:00 2001 From: jwage Date: Mon, 5 Oct 2009 05:42:30 +0000 Subject: [PATCH] [2.0] Adding EntityRepository::createQueryBuilder() method --- lib/Doctrine/ORM/EntityRepository.php | 14 ++++++++++++++ lib/Doctrine/ORM/Mapping/ClassMetadata.php | 1 + lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 1 + 3 files changed, 16 insertions(+) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 1c2c11d43..5b8563f9b 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -32,6 +32,7 @@ namespace Doctrine\ORM; * @link www.doctrine-project.org * @since 2.0 * @author Roman Borschel + * @author Jonathan H. Wage */ class EntityRepository { @@ -52,6 +53,19 @@ class EntityRepository $this->_class = $class; } + /** + * Create a new QueryBuilder instance that is prepopulated for this entity name + * + * @param string $alias + * @return QueryBuilder $qb + */ + public function createQueryBuilder($alias) + { + return $this->_em->createQueryBuilder() + ->select($alias) + ->from($this->_entityName); + } + /** * Clears the repository, causing all managed entities to become detached. */ diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index f3d2d8c14..62eb079d5 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -38,6 +38,7 @@ use Doctrine\Common\DoctrineException; * the serialized representation). * * @author Roman Borschel + * @author Jonathan H. Wage * @since 2.0 */ final class ClassMetadata extends ClassMetadataInfo diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index d73ba560f..9f6982000 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -38,6 +38,7 @@ use Doctrine\Common\DoctrineException; * the serialized representation). * * @author Roman Borschel + * @author Jonathan H. Wage * @since 2.0 */ class ClassMetadataInfo